Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575).
authorAlex Szpakowski <slime73@gmail.com>
Wed, 10 Apr 2019 22:30:58 -0300
changeset 127020ff5bbe35bf5
parent 12701 3477a301a5a8
child 12703 f6c7e5e03f60
Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575).
src/video/cocoa/SDL_cocoaopengl.m
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Wed Apr 10 10:59:53 2019 +0200
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Wed Apr 10 22:30:58 2019 -0300
     1.3 @@ -40,7 +40,7 @@
     1.4  DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
     1.5  {
     1.6      SDLOpenGLContext *nscontext = (SDLOpenGLContext *) displayLinkContext;
     1.7 -    
     1.8 +
     1.9      /*printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); */
    1.10      const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
    1.11      if (setting != 0) { /* nothing to do if vsync is disabled, don't even lock */
    1.12 @@ -208,6 +208,7 @@
    1.13      const char *glversion;
    1.14      int glversion_major;
    1.15      int glversion_minor;
    1.16 +    int interval;
    1.17  
    1.18      if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
    1.19  #if SDL_VIDEO_OPENGL_EGL
    1.20 @@ -319,6 +320,10 @@
    1.21          return NULL;
    1.22      }
    1.23  
    1.24 +    /* vsync is handled separately by synchronizing with a display link. */
    1.25 +    interval = 0;
    1.26 +    [context setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval];
    1.27 +
    1.28      if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    1.29          Cocoa_GL_DeleteContext(_this, context);
    1.30          SDL_SetError("Failed making OpenGL context current");