Ticket #523: SDLGLSWAPCONTROLWIN.patch

File SDLGLSWAPCONTROLWIN.patch, 1.3 KB (added by wacko, 3 years ago)

Patch for enable disable VSync Windows

  • wsdl.cpp

     
    261261 
    262262static int depth_bits = 24; // depth buffer size; set via SDL_GL_SetAttribute 
    263263 
     264typedef BOOL (APIENTRY *PFNWGLEXTSWAPCONTROLPROC)( int ); 
     265static int vSyncValue = 1; 
     266 
    264267// check if resolution needs to be changed 
    265268static bool video_NeedsChange(int w, int h, int cur_w, int cur_h, bool fullscreen) 
    266269{ 
     
    279282    return false; 
    280283} 
    281284 
     285void SetVSyncValue() { 
    282286 
     287  char* e = (char*)glGetString(GL_EXTENSIONS); 
     288 
     289  if(!e) 
     290    return; 
     291 
     292  if (!strstr(e, "WGL_EXT_swap_control")) 
     293    return; 
     294  
     295  PFNWGLEXTSWAPCONTROLPROC wglSwapEXT = (PFNWGLEXTSWAPCONTROLPROC) wglGetProcAddress("wglSwapIntervalEXT"); 
     296 
     297  if (!wglSwapEXT) 
     298    return; 
     299 
     300  wglSwapEXT(vSyncValue); 
     301} 
     302 
     303 
    283304int SDL_GL_SetAttribute(SDL_GLattr attr, int value) 
    284305{ 
    285306    if(attr == SDL_GL_DEPTH_SIZE) 
    286307        depth_bits = value; 
    287308 
     309  if (attr == SDL_GL_SWAP_CONTROL) { 
     310    vSyncValue = value; 
     311  } 
     312 
    288313    return 0; 
    289314} 
    290315 
     
    373398 
    374399        if(!wglMakeCurrent(g_hDC, hGLRC)) 
    375400            return 0; 
     401 
     402    // We should not have to call this here but since our code is not really friendly 
     403    // this will have to do!. 
     404    SetVSyncValue(); 
    376405    } 
    377406    else    // update the existing window 
    378407    {