Wednesday 23 July 2008

Was glut initialised?

I created small programs with freeglut and OpenGL that do useful stuff for me. But, when I tried to call its functions from other programs, I had lots of problems with glutInit.

The most common message I saw was
illegal glutInit() reinitialization attempt

Some of these problems I solved using the glutLeaveMainLoop. But not all of them. I needed to find out if glut was considered initialized or not. If only I could access the contents of the freeglut internal fgState.Initialised. But it is not possible without recompiling freeglut.

The solution I found is to call
int glut_time = glutGet(GLUT_ELAPSED_TIME);
if(glut_time > 0){
glutInit(&argc, argv);
}

This is the only way I found to know whether glut is initialised or not.

No comments: