Jump to content
  • Advertisement
Sign in to follow this  
floatingwoods

OpenGL one thread and OpenGL screen refresh

This topic is 3654 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

Hi, My application runs with one single thread. This means I have my window and dialog messages handling, then some calculation to move objects, then the rendering. After rendering the loop starts again with the messages handling and so on. This works very nicely and I don't have any major problem. This also gives me very consistent and smooth renderings (compared to a rendering thread in parallel to a calculation thread). My only problem is when I for instance move one dialog to a different position: then, the background (the OpenGL view) doesn't get refreshed until I release the mouse button. The solution I have come up with is to swap the rendering buffers everytime the dialog moves (I do this in the dialog's 'WindowProc' by monitoring the 'WM_WINDOWPOSCHANGING' message). I swap the rendering buffers twice in order to just refresh the background, because the two buffers might not contain the same image. So I do: SwapBuffers(mainWindow->hDC); SwapBuffers(mainWindow->hDC); However the first swap is also visible (escpecially on slow computers) and this makes my OpenGL content 'shake' when I move a dialog. How can I avoid this? Is it possible to swap the buffers without actualizing the window (for the first swap)? Or is it possible to obtain two swaps at once? Or to simply copy the current buffers's content to the window? Thanks

Share this post


Link to post
Share on other sites
Advertisement
If you move a dialog window and the GL window doesn't refresh, then yuo aren't handle rendering when WM_PAINT messages are sent. The problem is your applications. Personally, I've never had any problems.

Share this post


Link to post
Share on other sites
Yes, I always render the scene when a WM_PAINT message is sent.
If you want to backup your scene, you need to render to a FBO and then do FBO blitting or render to texture and render a texture quad that covers the scene.

Share this post


Link to post
Share on other sites
Ok, so is rendering to FBO supported by all systems/graphiccards? It seems a litle bit overkill to me, I just need to copy the last displayed buffer to the screen. Isn't there a simpler way of doing this?
Or would someone have a quick code sample ready for what I want to do? (using the FBO and doing the blitting) I would appreciate a lot.
Another related question: if I render to the FBO, is that like rendering to an internal buffer that I can then use for other things (e.g. check the depth values, etc.)? I know that when checking the regular OpenGL buffer, it only works when there is no other window in the way...

Thanks

Share this post


Link to post
Share on other sites
It depends on what you are targetting. It seems as if all drivers that support GL 2.0 or 2.1 support the FBO extension. In GL 3, it became core and some changes are made like relaxing the restrictions.

Much older cards like TNT, Geforce 256 are no longer supported by nVidia.
However, they support p-buffers but that's not easy to work with.

An FBO is an offscreen buffer. So is p-buffer.
Examples can be found in the extension spec.

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!