Box2D 和 glut。帧率问题

发布于 2024-12-15 14:55:47 字数 354 浏览 5 评论 0原文

我在让 glutTimerFunc() 与 box2d 的 world->step(); 很好地配合时遇到问题

以下是我传递给它们的值。

glutTimerFunc(0, timer, 0);
world->Step((1.0f/60.0f), 8, 6);

问题是,当timerFinc为0时,图形没有时间正确渲染,因此我的图形变得跳跃。如果我将任何其他值传递给timerFunc,我的图形基本上就会停止,无论是1、20还是之间的任何值。我也无法将其他值传递到 world->step 中,否则事情会变得非常混乱。

有什么办法可以让两者一起运行吗?或者也许我错过了一些东西。

I am having problems getting glutTimerFunc() to play nicely with box2d's world->step();

Here are the values I'm passing into them

glutTimerFunc(0, timer, 0);
world->Step((1.0f/60.0f), 8, 6);

The problem with this is that with the timerFinc at 0 the graphics don't have time to render properly so my graphics become jumpy. If I pass any other value into timerFunc my graphics basically come to a standstill be it 1, 20 or any value in between. I also can't pass other values into world->step without things getting very messy.

Is there some way I can get the two to run together. Or maybe I'm missing something.

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

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

发布评论

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

评论(1

萌梦深 2024-12-22 14:55:47

如果您有严格的计时需求,例如游戏或物理模拟,则根本不应该使用 FreeGLUT。尝试使用GLFW。它允许您手动管理渲染循环,因此您可以完全控制时间。

If you have strict timing needs, such as for a game or physics simulation, you should not be using FreeGLUT at all. Try GLFW instead. It allows you to manage the rendering loop manually, and thus, you have full control over timing.

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