什么可能导致 OpenGL 在“开始调试”下表现不同?与“启动而不调试”选项?
我用 C++ 编写了一个 3D 立体 OpenGL 程序。我在 timeBeginPeriod(1) 之后使用 timeGetTime 跟踪显示中对象的位置。当我使用“开始调试”运行程序时,我的对象在显示屏上平滑移动(正如它们应该的那样)。当我使用“启动而不调试”运行程序时,对象偶尔会冻结几次屏幕刷新,然后跳转到新位置。关于可能导致此问题的原因以及如何解决它有什么想法吗?
编辑:如果单击鼠标按钮,当我运行“启动而不调试”时,似乎可以在短暂的延迟后解决抖动问题。我的应用程序是一个控制台应用程序(程序首次启动时我接受一些参数)。这两个选项之间的窗口焦点可能存在差异吗?当我完成从控制台窗口的输入时,是否有一种明确的方法可以将焦点强制到 OpenGL 窗口(通过 glutFullScreen(); 以全屏显示)?
谢谢。
I have written a 3D-Stereo OpenGL program in C++. I keep track of the position objects in my display should have using timeGetTime after a timeBeginPeriod(1). When I run the program with "Start Debugging" my objects move smoothly across the display (as they should). When I run the program with "Start without debugging" the objects occationally freeze for several screen refreshes then jump to a new position. Any ideas as to what may be causing this problem and how to fix it?
Edit: It seems like the jerkiness can be resolved after a short delay when I run through "Start without debugging" if I click the mouse button. My application is a console application (I take in some parameters when the program first starts). Might there be a difference in window focus between these two options? Is there an explicit way to force the focus to the OpenGL window (in full screen through glutFullScreen();) when I'm done taking input from the console window?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
timeGetTime
API 的精度仅为 10 毫秒。如果您测量的间隔小于 50 毫秒左右,您可能只是看到系统计时器中预期差异的影响。我不知道为什么调试器会对此产生影响,但是系统的整个工作原理是一个黑匣子。您可以使用 QueryPerformanceCounter 来获得更高的性能- 解决时间,这可能会有所帮助。The
timeGetTime
API only has a precision of something like 10ms. If the intervals you're measuring are less than 50ms or so, you may simply be seeing the effects of the expected variance in the system timer. I have no idea why the debugger would have an effect on this, but then the whole workings of the system are a black box. You could use the QueryPerformanceCounter to get higher-resolution timings, which may help.导致任何程序在调试和未调试时行为不同的最常见原因是使用未初始化的变量,尤其是读取未初始化的内存。检查一下你是否没有这样做。
一些更具体的 OpenGL - 您可能会在刷新命令时遇到一些问题。尝试在绘制每一帧后插入
glFinish()
。以某种方式真正确保发生冻结时确实有帧正在渲染而不是整个应用程序被冻结也可能会有所帮助。如果有的话,你更有可能在逻辑上有一些错误,因为 OpenGL 似乎完成了它的工作。
The most common thing that causes any program to behave differently while being debugged and not being debugged is using uninitialized variables and especially reading uninitialized memory. Check that you're not doing that.
Something more OpenGL specific - You might have some problems with flushing of commands. Try inserting
glFinish()
after drawing every frame.It might also be helpful to somehow really make sure that when the freeze occurs there are actually frames being rendered and not that the whole application is frozen. If there are its more likely that you have some bug in the logic since it seems that OpenGL does its job.