Under Linux, GLUT's display func called only once

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.

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?

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.

BTW some other differences between glut and freeglut are

  • what callbacks are NOT called when menu is active
  • what’s absolute size of mouse coordinate changes in passive callback
  • freeglut doesn’t work in vista

On the other hand, I haven’t found any differences between 32bit and 64bit versions.

Yes, it’s definitely being done.

The Linux I’m using is 64-bit Slackware (slamd64).

I could install 32-bit Slackware also and see if that would make a difference.

I’m using Mesa and the latest GLUT 3.7.6.

I strongly suggest trying the latest FREEGLUT instead.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.