Solved

glutdisplay function

Posted on 2008-06-13
6
516 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

825 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