Front buffer getting cleared

When another window is dragged over an OpenGL viewport, It erases the underlying pixels:
http://www.leadwerks.com/post/glprob.jpg

I tried adding the CS_SAVEBITS style to the window, which had no effect:
style=GetClassLong(HWND,GCL_STYLE)+CS_SAVEBITS
SetClassLong hwnd,GCL_STYLE,style

Here is a demo which demonstrates the problem. I need to either set the window so it “saves” the underlying pixels, or I need to detect the repaint event and flip the buffer. Please help:
http://www.leadwerks.com/post/glprob.zip

The title bar displays the hwnd to the window, so you should be able to tweak the window as the program runs.

Okay, I was able to detect the WM_PAINT message, but how do I swap the buffer more than once without redrawing the scene? I don’t want to re-render everything if nothing has changed.

Originally posted by halo:
Okay, I was able to detect the WM_PAINT message, but how do I swap the buffer more than once without redrawing the scene? I don’t want to re-render everything if nothing has changed.
In “unextended” WGL the content of the backbuffer is undefined after calling SwapBuffers.

If glAddSwapRectWIN is supported, you can use the PIXELFORMATDESCRIPTOR flags PFD_SWAP_COPY and PFD_SWAP_EXCHANGE when you request your pixelformat. Note that those are hints and may not be supported by the driver, so check back the real pixelformat of your OpenGL context by calling DescribePixelFormat .

If your driver doesn’t provide you with a PFD_SWAP_COPY pixelformat, you can use glCopyPixels instead of SwapBuffers to swap the whole backbuffer or the damaged regions of your rendering.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.