Solved

glutdisplay function

Posted on 2008-06-13
6
517 Views
Last Modified: 2013-12-21
I want to have the class object as a parameter in Display(common *s) function (where common is a class)  which is called in glutDisplayFunc(Display)
 But it shows error that i should not use parameters in display func.....Is there any way to  do it....?
0
Comment
Question by:jsbsudha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21777913
>> But it shows error that i should not use parameters in display func.....

That is correct. The function pointer passed as argument to glutDisplayFunc Has to have this signature :

        void fun(void);

ie. taking no arguments, and returning nothing.


If you want to have data available to the function, there are several ways of doing that.

1) if the object will always be the same object, you can make it a static local of the function :

        void Display() {
            static common *s;
            /* the code */
        }


2) if the object will change for every call to the function, then you can make it a global :

        common *s;
        void Display() {
            /* the code */
        }
0
 

Author Comment

by:jsbsudha
ID: 21778123
At present I had made the object as a global.......so i will come to you after some time.....
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21778152
>> so i will come to you after some time.....

What do you mean ? Is your question answered, or do you need further assistance with this?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jsbsudha
ID: 21778564
As I am working on the task of  converting the procedural way program into object oriented way...... I would like to ask some other doubt regarding this usage of global object....now i could not  accept your solution readily.......if i find that everything works fine if I declare it as a global object......then i can close this question............

Thank you
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21778602
ok :)
0
 
LVL 20

Expert Comment

by:ikework
ID: 21788599
hey jsbsudha, i8 gave you the only possible answer(s) .. please be so kind and pay a little respect to that, dont wait months to close it, it would just be fair to do so, because he tried to help you and he did .. remember its a give and take here .. :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to start eclipse ? 17 163
Header of docx file 17 132
Embarcadero C++ builder XE10.1 Berlin TRegistry declaration 1 48
Outlook 13 84
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question