Sign in to follow this  
Kincaid

Best Place for Render Call ??

Recommended Posts

What is the best place to place the render call ???? of course i've worked with a simple loop and calling every frame. now im trying placing the render call at the WM_PAINT messages in the window callback (whats the thought about this???) And i should try more timers I guess. (any suggestions?) (I have multiple viewports, and possibly some loose render areas (preview windows e.g.). I need to update them all when editing in one etc, while there are some independant from the rest. (so I thougt the WM_PAINT would be a pefect place.. but not sure about all the details..) thanx

Share this post


Link to post
Share on other sites
The timer callback is a good place to post the redisplay if you want it to refresh every so often, and it works well most of the time, but you have to keep in mind that slower machines might not be able to render the scene every time the timer sequence comes up, so you might end up with some strange things happening.

I usually post the redisplay in the idle callback, and do any rotations/translations/etc. in the timer callback, so you know those things will all be done at the same time, and the machine is free to refresh whenever it has enough spare resources.

Share this post


Link to post
Share on other sites
If you call your rendering function (in case of double buffering, including a buffer swap) at every WM_PAINT message, you will be able to display something, but changing what is displayed will only be possible when the message is posted or when you call your rendering function somewhere else.
For as far as I know, WM_PAINT messages are posted when the window is moved, activated or resized (among other things). This is all well for static scenes, but not very useful for something more dynamic using, for instance, animations. In this case, the rendering function is commonly called as often as the monitor refresh rate, making it unnecessary to also call it for every WM_PAINT message.

If you use multiple viewports that you wish to update independently, you should look into using seperate device contexts and opengl contexts for their windows. Then you can switch between them using wglMakeCurrent and a call to SwapBuffers will only swap the buffers for one viewport.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this