Qt 4 中的 OpenGL 更新率

发布于 2024-10-07 15:11:53 字数 333 浏览 0 评论 0原文

我正在 Qt 4.7 中开发一个使用 OpenGL 的应用程序。 我知道必须调用 updateGL() 才能刷新视图,从后台缓冲区进行交换,但是应该多久执行一次?
它应该尽可能频繁地完成,因为我正在显示动画(即没有静态图像)。
我知道最大速率(fps)将是显示器刷新的倍数。假设显示器垂直刷新频率为 50hz。 updateGL() 最多应每 20 毫秒调用一次。
如果 updateGL() 需要超过 20 毫秒才能完成,会发生什么情况?
如果我每隔 1 毫秒调用 updateGL() 会有什么问题吗? (即队列中的 updateGL() 调用事件导致堆栈溢出?

I'm developing an application in Qt 4.7 which makes use of OpenGL.
I know updateGL() must be called in order to refresh the view, making a swap from the backbuffer but, how often should it be done?
It should be done as frequently as possible because i'm showing an animation (i.e. no static images).
I know the biggest rate (fps) will be multiple of the monitor refresh. Let's suppose monitor vertical refresh if 50hz. updateGL() should be called at most every 20 ms.
What happens if updateGL()'s takes more than 20 ms to complete?
There would be any problem if i call updateGL() every, let's say, 1 ms? (i.e. overflowing a stack with queued updateGL() call events?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2024-10-14 15:11:53

交换通常会等待垂直同步,因此您可以根据需要多次调用它,不会出现剪切或伪影(以防您担心)。

对于 Qt 事件,要么使用设置为快速的 QTimer(如果事件处理得不够快,这会默默地丢弃事件,即没有升级事件队列),或者,您可以在 updateGL 末尾发布重绘事件,本质上是调用自己。

后者可能不适合您,但这是确保您的绘画循环尽可能快地运行(但不是更快)的巧妙方法。 ;)

The swap usually waits for vsync, so you can call it as often as you like, you won't be getting shearing or artifacts (in case you were worried).

W.r.t. Qt events, either use a QTimer set to fast (this silently discards events if they are not processed fast enough, i.e. no escalating event queue), or, you could post a redraw-event at the end of updateGL, essentially calling yourself.

The latter might not suit you, but it's an neat way of ensuring your paint loop runs as fast as possible, but not faster. ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文