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?
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
Don't forget to include <OpenGL/gl.h>
It's not the nicest solution but it's actually the only one I found that work like a charm.
[NSOpenGLContext setValues:&value forParameter:NSOpenGLCPSwapInterval]
–
Tayyebeb kCGLCPSwapInterval
/ NSOpenGLCPSwapInterval
/ CVDisplayLink
–
Thermomagnetic flushBuffer()
must not be put in func draw(_ dirtyRect: NSRect)
–
Thermomagnetic This enabled me to get around ~700 frames per second on my MacBook Pro.
- Download Graphics Tools for Xcode - Late August 2014
- Install or just mount Graphic Tools
- Open Quartz Debug
- Go to Tools -> Show Beam Sync Tools
- Select Disable Beam Synchronization
It is not permanent either, perfect for testing/benchmarking.
Your session has expired. Please log in.
. –
Chunchung Welcome to SO. I outlined an approach here for a similar question. You should consider that most Mac LCDs are locked to 60Hz, and more recent hardware is limited to 120Hz. Disabling vsync may simply result in wasted CPU/GPU cycles, and possibly introduce tearing artifacts.
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
Don't forget to include <OpenGL/gl.h>
It's not the nicest solution but it's actually the only one I found that work like a charm.
[NSOpenGLContext setValues:&value forParameter:NSOpenGLCPSwapInterval]
–
Tayyebeb kCGLCPSwapInterval
/ NSOpenGLCPSwapInterval
/ CVDisplayLink
–
Thermomagnetic flushBuffer()
must not be put in func draw(_ dirtyRect: NSRect)
–
Thermomagnetic © 2022 - 2024 — McMap. All rights reserved.