opengl main loop

Started by
5 comments, last by BlackSeeds 15 years, 8 months ago
I registered a rendering function as the display callback funcion. Problem is that the render function is called only when I move the window or the window is obscured. How in opengl do I make the rendering function to be called when I need it ? How does the main loop function works ? thx.
There is nothing that can't be solved. Just people that can't solve it. :)
Advertisement
are you using double buffering? I know if you only use single buffering then the display will update only if you minimize then maximise the window.

Also what are you using (Win32, GLUT)? if you post some more info, should be able to help :)

If you use win32 you need to call the rendering function within the main loop, and call SwapBuffers(hDC). in glut you can call glutPostRedisplay() in the timer function to invoke the display callback.
I am using GLUT (in linux). What is the timing function you mentioned ?
I'll check the buffer issue.

thx.
There is nothing that can't be solved. Just people that can't solve it. :)
in glut I create a callback glutTimerFunc() which gets executed each frame (sorry I cant post source I'm at work) in here I do my logic and timer updates things like that and then call glutPostRedisplay() which invokes the display to get called again.

I think things to check are
-double buffering (if you expect any animation or moving objects)
-check you swap buffers
-check you call glutPostRedisplay() to make the display function go again. You can call this from inside the display function itself if you don't have a timer.

this should fix it.

If you still have issues just post some source
Well I tried using a timer function but the glutPostReDisplay doesn't do anything (the view doesn't change). When I use my rendering function as the idle function it works great but I have a feeling this is not a good idea using it as idle.

How do you use the timing function correctly ?

thx.
There is nothing that can't be solved. Just people that can't solve it. :)
What you're trying to achieve is explained here (in the section on glut).
Quote:Original post by Gage64
What you're trying to achieve is explained here (in the section on glut).


yeah Example 1-3 in that article is what I think you need :)

This topic is closed to new replies.

Advertisement