开发者

How to set FPS to 30 with opengl? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

so how? 开发者_如何学编程my app is running at 60FPS, but i want 30.


Assuming you have a target frame rate, you could measure how long its been since the last time you finished rendering. From there, you could sleep for targetMsPerFrame - timeElapsed.


one word: sleep


Take a look at WGL_EXT_swap_control or GLX_EXT_swap_control extensions, regarding to your operating system. This is used to control the VSync, but should be usefull to render at half your monitor refresh rate.


@itzWarty has a correct answer on how to set your framerate. It's called "clamping" or "locking" the framerate.

But why do you want to do that? If you're trying to avoid hogging resources, clamping the framerate is good.

Otherwise you might want to let framerate go as fast as possible, in order to make people with great honking graphics cards feel like they didn't waste their money. In that case you need to make your animation time-based rather than frame-based. I.e. scale your animation steps according to how much time has passed since the previous step. E.g.

x += dx * (timeNow - timePrev) / typicalDuration; // pseudoCode
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜