How to draw OpenGL content when resizing win32 window

When resizing a win32 window with an OpenGL context, it simply shows black in the newly opened area. I get a WM_PAINT message when resizing, and I'm trying to display new content, but it seems that SwapBuffers is not doing anything by resizing.

How to resize the window so that when resizing there is no "broken" content?

+7
source share
1 answer

This usually happens if you have a background brush configured for your window class (see the WNDCLASS or WNDCLASSEX structure). If there is a brush, the system will clear the window immediately after each redraw step, and then send WM_PAINT. In the case of V-Synced SwapBuffers, your image can be reset to the next resizing step before the swap buffer occurs or immediately after it, but before this part of the screen has been sent to the display device.

In any case, the solution is to set the brush in the background to NULL. Also processing the results of processing WM_ERASEBKGND messages can produce results.

EDIT due to comment

If the contents of the last frame remain visible, you probably just don’t respond to resizing using redrawing. The simplest solution for this is to call the drawing function from the WM_SIZING message handler (or WM_SIZE, just try both).

+6
source

All Articles