Jump to content
  • Advertisement
Sign in to follow this  
DesignerX

OpenGL opengl main loop

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!