src/video/cocoa/SDL_cocoaopengl.m
changeset 12702 0ff5bbe35bf5
parent 12503 806492103856
child 12706 d7782848eb50
     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");