Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I use a class to write opengl program in C++,I want to use glutDisplayFunc(display)
and this my display function:
C#
void graphic::dispaly()
{
    glClear(GL_COLOR_BUFFER_BIT);
    //call a function
    glutSwapBuffers();
}


Now ,I face this error:
3 IntelliSense: argument of type "void (graphic::*)()" is incompatible with parameter of type "void (*)()"

I googled and fount this solation:
http://stackoverflow.com/questions/3589422/using-opengl-glutdisplayfunc-within-class[^]

but I cant understand it!,please help me to use this function correctly .
(Sorry for my bad English:))
Posted
Comments
Richard MacCutchan 29-Oct-13 10:01am    
OK, having looked at the SO link, it is clear that your callback routine must be a static function.

1 solution

As Richard said, declare the display function in your graphic class as:
C++
class graphic
{
   ...
   static void display ();
};

and things should work.
 
Share this answer
 
Comments
Mohammad Sharify 29-Oct-13 23:48pm    
tnx,a lot! it solved ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900