Click to See Complete Forum and Search --> : OpenGL glutDisplayFunc()


H-N-N
October 4th, 2004, 07:38 PM
Hi there,

I want to set the OpenGL paint function by calling glutDisplayFunc( paintGL() )paintGL(void) returns void and includes glBegin() & glEnd() etc...

My compiler (VC++ 6) says:
"cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)"

This project should be independant of MFC and MS specific functions. Calling glutDisplayFunc( &paintGL() ) does not change anything.

This function looks like followed:
void View::paintGL(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glLoadIdentity();
gluLookAt(0,0,5,0,0,0,0,1,0);

glBegin(GL_LINES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);

glutSwapBuffers();
glEnd();
glFlush();
}
Do you have a clue what could be wrong?
Thank you alot in advance!!

Holger

zach
October 5th, 2004, 06:01 AM
glutDisplayFunc() is a C function which does not accept member functions (C++ calling conventions). Try making it a global function for testing purposes. Maybe making it static could solve the problem, but I'm not sure about this.

Bornish
October 5th, 2004, 06:06 AM
Try:glutDisplayFunc( &View::paintGL )Regards,

H-N-N
October 5th, 2004, 09:36 AM
Thanks guys,

I now declared them as static. That helped!

Thanks alot!



Holger