I have some OpenGL/GLUT/GLUI code that I developed under Windows and assumed would work under Linux. What I’ve found however is that the GLUT display function is called only once. In my code I call glutPostRedisplay() wherever needed and everything works swimmingly under Windows.
Is there something special that has to be done under Linux?
Do you call glutPostRedisplay() from idle callback? Linux version (probably freeglut) was developed separately from windows version, so there are minor differences also in menu handling etc.
Hi,
No I’m calling glutPostRedisplay() from wherever is convenient, usually just before I return to GLUT’s main loop.
Is it necessary to call from the idle callback?
Thanks.
No, it’s not necessary to call glutPostRedisplay() from the idle function.
One possibility is to call glutPostRedisplay() at the end of your display function, for the maximum possible redraw rate.
The other approach is to call glutPostRedisplay() only when necessary, eg. when you changed your scene in response to user input or a timer for an animation.
Whenever your window has been (partially) occluded an becomes visible again, was minimized and gets maximized again, … glut should trigger an redraw by itself.
Since the later sounds to be your approach, i would guess some callback function is missing a call to glutPostRedisplay().
Nope, I call glutPostRedisplay as needed and the code works fine under Windows.
For example, I have mouse callbacks that handle rotating the model, and they update GLUI text widgets to show the new angle. The widgets are getting updated, but not the model.
I’m using 64 bit Linux so perhaps there is something about Mesa that isn’t 64-bit safe.
I guess the problem is more likely to be on the GLUT implementation used. Do you use the original GLUT, openglut, or Freeglut (the later is preferred) ?
That is what i meant. You do some changes that alter what should be drawn on screen (being it the modelview or projection matrix, model data, glui elements, … you name it).
In order to have these changes applied you need to redraw the window.
So did you make sure to call glutPostRedisplay() from the said mouse callback ?
Right. My guess is that the GLUT implementation he uses on windows might trigger more redraw events on its own (like, for example, after user input callbacks).
Because if that is not the case, it would mean that his linux implementation misses redraw events, which i would deem less likely. But i can be mistaken on this one, of course.