PDA

View Full Version : Problems with the simplest code with opengl



tirengarfio
07-25-2006, 03:16 AM
Hi,

with the code below, that i copy from the first chapter of an openGL tutorial, i recieve this error message:

error C2664: 'glutDisplayFunc': cannot convert parameter 1 from 'void (void)' to 'void(__cdecl *)(void)'


#include <GL/glut.h>
#define ANCHO 640
#define ALTO 400

void CALLBACK display_cb (void)
{
glClear (GL_COLOR_BUFFER_BIT);
glFlush();
}

void inicializacion (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0);
glShadeModel (GL_FLAT);
}

int
main (int argc, char** argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (ANCHO, ALTO);
glutCreateWindow ("Primer programa OpenGL");
glutDisplayFunc (display_cb);

inicializacion();
glutMainLoop();

return 0;
}

RigidBody
07-25-2006, 04:21 AM
maybe you should change

void CALLBACK display_cb (void)

to

void display_cb (void)

k_szczech
07-25-2006, 04:25 AM
Just look for glutDisplayFunc in glut.h - you will find that it takes void(*)(void).
Your compiler uses __cdecl by default so it added it when compiling glut.h, but you have bypassed this default setting in your function by using CALLBACK.