Solved

glutdisplay function

Posted on 2008-06-13
6
507 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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
>> 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:jsbsudha
Comment Utility
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
Comment Utility
ok :)
0
 
LVL 20

Expert Comment

by:ikework
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now