简体   繁体   English

不断更新Opengl窗口

[英]update Opengl window continuously

I'm using Qt and OpenGL and GLEW to map a texture on a quad and render it. 我正在使用Qt以及OpenGL和GLEW在四边形上映射纹理并将其渲染。 I want to change the texture for each frame and update the window continuously. 我想更改每帧的纹理并连续更新窗口。 How can I force it to update continuously? 如何强制它不断更新?

The problem is solved as mentioned in the comments by adding a timer and connecting it to a slot to signal update function. 如注释中所述,通过添加计时器并将其连接到插槽以发出信号更新功能,可以解决该问题。

If you mean swap the buffers you need to call your platform specific swap function (wglSwapBuffers, glXSwapBuffers etc.) every frame and make sure vsync is disabled. 如果要交换缓冲区,则需要每帧调用特定于平台的交换函数(wglSwapBuffers,glXSwapBuffers等),并确保禁用vsync。 If you mean let the window resize it's not an open gl specific question, that's down to the windowing system, also. 如果您的意思是让窗口调整大小,这不是一个特定于gl的问题,那也取决于窗口系统。

If you are using qt to create the window and manage the events like when the mouse is moving, it may cause the application to wait for an event to happen before re-drawing the window. 如果使用qt创建窗口并管理事件(如鼠标移动时),则可能导致应用程序等待事件发生,然后重新绘制窗口。 I think you could use a QTimer object and connect its timeout signal to your update function. 我认为您可以使用QTimer对象并将其超时信号连接到您的更新函数。

Otherwise, if you handle events with some waitEvent() function, change it with a non-blocking version. 否则,如果使用某些waitEvent()函数处理事件,请使用非阻塞版本进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM