当光标位于 GLUT UI 时进行 OpenGL 渲染
我有一个主窗口,它在屏幕的顶部 10% 处有一个过剩的 UI,在屏幕底部的 90% 处有 openGL 世界。每次我的光标开始悬停在 GLUT 部分上时,openGL 渲染都会冻结。仅当光标退出 GLUT 区域时才恢复。
这是因为只要光标悬停在 GLUT 区域上,就可能永远不会调用 glutIdleFunc,因为 glut 不是“空闲”,因此不会渲染 openGL 内容。
我已经尝试创建一个新的不相关线程,仅调用显示代码和/或 glutPostRedisplay,但我得到了高达 20 fps 的帧速率,而不是正常方式的 100+ fps。我不知道到底为什么。 (在这个测试中,我还禁用了 glutIdleFunc,因此没有空闲函数,只有调用显示的单独线程)
解决这个问题的方法(除了“停止使用 glut”,我将来可能会这样做,但现在我想要一个临时解决方案)?
I have a main window which has both a glut UI in the top 10% of the screen, and the openGL world in the bottom 90% of the screen. Every time my cursor starts hovering over the GLUT portion, openGL rendering will freeze. It resumes only when the cursor exits the GLUT area.
This is because as long as the cursor is hovering over the GLUT area, presumably glutIdleFunc is never called because glut is not "idle", so openGL stuff is not rendered.
I already tried making a new unrelated thread that just calls the display code and/or glutPostRedisplay but I got a framerate of whopping 20 fps as opposed to the 100+ fps the normal way. I don't know exactly why. (In this test I also disabled glutIdleFunc so there is no idle func, just the separate thread calling the display)
Ways to get around this (other than "stop using glut" which I might do in the future but for now I would like a temporary solution)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个老问题,但我遇到了类似的问题,想分享我是如何解决它的。
基本上,在空闲函数中,您应该手动将窗口设置为正常的窗口 ID。感谢 Joel Davis 的 HexPlanet 代码 ( https://github.com/joeld42/hexplanet/ )证明这一点:
I know this is an old question, but I was having a similar issue and wanted to share how I solved it.
Basically, in your idle function, you should manually set the window to your normal window ID. Thanks to Joel Davis' HexPlanet code ( https://github.com/joeld42/hexplanet/ ) for demonstrating this:
为被动运动函数创建回调:
并使用以下方法注册它:
Create a callback for passive motion func:
And register it using: