如何在调整Win32窗口大小的同时绘制OpenGL内容 [英] How to draw OpenGL content while resizing win32 window

查看:91
本文介绍了如何在调整Win32窗口大小的同时绘制OpenGL内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用OpenGL上下文调整win32窗口大小的同时,它在新暴露的区域上仅显示黑色. 调整大小时确实收到WM_PAINT消息,并且确实尝试呈现新内容,但是好像SwapBuffers在调整大小时不执行任何操作.

While resizing win32 window, with OpenGL context, it just shows black on the newly exposed area. I do get WM_PAINT message while resizing, and I do try to render new content, but it seems as if SwapBuffers does nothing, while resizing.

如何正确处理窗口大小调整,以便在调整大小时没有残破"的内容?

How should window resizes be handled correctly, so that there is no "broken" content while resizing?

推荐答案

如果为窗口的类配置了背景画笔,通常会发生这种情况(请参见WNDCLASS或WNDCLASSEX结构).如果有刷子,则系统将在每个重绘步骤之后立即清除窗口,然后发送WM_PAINT.如果是V同步SwapBuffers,则可能在缓冲区交换发生之前或之后,但在那部分屏幕被发送到显示设备之前,通过下一个调整大小步骤覆盖了您的图片.

This usually happens if you have a background brush configured for your window's class (see the WNDCLASS or WNDCLASSEX structure). If there's a brush, the system will clear the window right after each redraw step, then send the WM_PAINT. In case of V-Synced SwapBuffers your picture may have been overdrawn by the next resizing step before the buffer swap happened, or just right after it, but before that part of the screen was sent to the display device.

无论哪种方式,解决方案都是将窗口的背景画笔设置为NULL.修改WM_ERASEBKGND消息处理也可能会产生结果.

Either way, the solution is to set the background brush of the window to NULL. Also tinkering with the WM_ERASEBKGND message handling may give results.

由于评论需要编辑

如果最后一帧的内容保持可见,则可能只是不对重新绘制大小作出反应.最简单的解决方案是从WM_SIZING(或WM_SIZE,只需尝试两者)消息处理程序中调用绘图函数.

If the content of the last frame stays visible, you probably just don't react to resizing with a redraw. The easiest solution to this is calling the drawing function from the WM_SIZING (or the WM_SIZE, just try both) message handler.

这篇关于如何在调整Win32窗口大小的同时绘制OpenGL内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆