PDA

View Full Version : Under Linux, GLUT's display func called only once



Yarmy
08-29-2008, 12:22 PM
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?

Thanks.

Dee.cz
08-30-2008, 03:14 AM
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.

Yarmy
08-30-2008, 12:15 PM
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.

S.Seegel
08-30-2008, 02:41 PM
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().

Yarmy
08-31-2008, 04:43 PM
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.

ZbuffeR
09-01-2008, 01:14 AM
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) ?

S.Seegel
09-01-2008, 02:03 AM
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.
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 ?


I guess the problem is more likely to be on the GLUT implementation used.
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.

Dee.cz
09-01-2008, 12:56 PM
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.

Yarmy
09-06-2008, 07:24 AM
So did you make sure to call glutPostRedisplay() from the said mouse callback ?


Yes, it's definitely being done.



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.

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.

Yarmy
09-06-2008, 07:48 AM
BTW some other differences between glut and freeglut are...


I'm using Mesa and the latest GLUT 3.7.6.

ZbuffeR
09-07-2008, 12:59 PM
I strongly suggest trying the latest FREEGLUT instead.