Solved

glutdisplay function

Posted on 2008-06-13
6
518 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

729 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