如何在macOS上禁用vsync [英] How to disable vsync on macOS

查看:570
本文介绍了如何在macOS上禁用vsync的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我所有的SDL/OpenGL程序中,帧速率都停留在60fps,因此看起来vsync已启用,但不是我启用的,也不是在我的代码或设置中启用的.所以我想现在是否有办法禁用它,也许是在某些深层的macOS设置中?

With all my SDL/OpenGL programs, the framerate is stuck at 60fps, so looks like the vsync is enable, but not by me, nor in my code or my settings. so i would like to now if there is a way to disable it, maybe in some deep macOS settings?

推荐答案

在多年之后寻找解决方法(并在布雷特·黑尔(Brett Hale))对我有用-我在渲染循环开始时添加了这段代码(不仅在init中,因为苹果似乎每次都重置SwapInterval设置.) ),最终能够使帧速率不同步:

After YEARS looking for a workaround (and with the help of Brett Hale) this is what worked for me - I've added that piece of code at the start of my render loop (and not only in the init, as Apple seems to reset the SwapInterval settings every time...) and was finally able to have unsynchronize framerate:

#ifdef __APPLE__
GLint                       sync = 0;
CGLContextObj               ctx = CGLGetCurrentContext();

CGLSetParameter(ctx, kCGLCPSwapInterval, &sync);
#endif

别忘了包含<OpenGL/gl.h>

这不是最好的解决方案,但实际上,这是我发现的唯一一种魅力十足的解决方案.

It's not the nicest solution but it's actually the only one I found that work like a charm.

这篇关于如何在macOS上禁用vsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆