Reputation: 1125
I want to make 3 windows to represent rotation around the given axis.
For that I made a class XYZAxis
which contain function render
.
Next, from the main I call the function creatWindow
which makes a GLUT window.
However I don't know how to correctly pass function render to glutDisplayFunc
:(
fragment of main
void (XYZAxis::* pmf)(void);
pmf = &XYZAxis::render;
XYZAxis *xaxis=&XYZAxis(origin,5,10);
glutDisplayFunc( void(xaxis->*pmf)() ) ;
glutIdleFunc(void(xaxis->*pmf)());
and a function within XYZAxis class
void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
this->orientation=this->orientation*(this->angle);
this->draw();
glutSwapBuffers();
}
the program compiles however when it reaches the glutMainLoop()
;
it throws an error and closes the window
GLUT: Warning in (unamed): The following is a new check for GLUT 3.0; update your code. GLUT: Fatal Error in (unamed): redisplay needed for window 1, but no display callback.
how to do it correctly?any ideas?
Upvotes: 0
Views: 585
Reputation: 34537
I don't think you can pass a pointer to a C++ instance method to a C API like GLUT. You will need to wrap the method call in a C function using a global pointer to the instance you are interested in. See http://www.parashift.com/c++-faq-lite/pointers-to-members.html
Upvotes: 1