Skip to content

Commit

Permalink
Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575).
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Apr 11, 2019
1 parent aae4901 commit 00c824a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/video/cocoa/SDL_cocoaopengl.m
Expand Up @@ -40,7 +40,7 @@
DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
{
SDLOpenGLContext *nscontext = (SDLOpenGLContext *) displayLinkContext;

/*printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); */
const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
if (setting != 0) { /* nothing to do if vsync is disabled, don't even lock */
Expand Down Expand Up @@ -208,6 +208,7 @@ - (void)dealloc
const char *glversion;
int glversion_major;
int glversion_minor;
int interval;

if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
#if SDL_VIDEO_OPENGL_EGL
Expand Down Expand Up @@ -319,6 +320,10 @@ - (void)dealloc
return NULL;
}

/* vsync is handled separately by synchronizing with a display link. */
interval = 0;
[context setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval];

if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
Cocoa_GL_DeleteContext(_this, context);
SDL_SetError("Failed making OpenGL context current");
Expand Down

0 comments on commit 00c824a

Please sign in to comment.