@@ -3321,8 +3321,10 @@ DXGI_FORMAT skg_ind_to_dxgi(skg_ind_fmt_ format) {
33213321
33223322 typedef BOOL (*wglChoosePixelFormatARB_proc) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
33233323 typedef HGLRC (*wglCreateContextAttribsARB_proc) (HDC hDC, HGLRC hShareContext, const int *attribList);
3324+ typedef BOOL (*wglSwapIntervalEXT_proc) (int interval);
33243325 wglChoosePixelFormatARB_proc wglChoosePixelFormatARB;
33253326 wglCreateContextAttribsARB_proc wglCreateContextAttribsARB;
3327+ wglSwapIntervalEXT_proc wglSwapIntervalEXT;
33263328#endif
33273329
33283330#ifdef _SKG_GL_LOAD_GLX
@@ -3830,6 +3832,7 @@ int32_t gl_init_wgl() {
38303832 // Function pointers we need to actually initialize OpenGL
38313833 wglChoosePixelFormatARB = (wglChoosePixelFormatARB_proc )wglGetProcAddress (" wglChoosePixelFormatARB" );
38323834 wglCreateContextAttribsARB = (wglCreateContextAttribsARB_proc)wglGetProcAddress (" wglCreateContextAttribsARB" );
3835+ wglSwapIntervalEXT = (wglSwapIntervalEXT_proc )wglGetProcAddress (" wglSwapIntervalEXT" );
38333836
38343837 // Shut down the dummy so we can set up OpenGL for real
38353838 wglMakeCurrent (dummy_dc, 0 );
@@ -3902,6 +3905,9 @@ int32_t gl_init_wgl() {
39023905 skg_log (skg_log_critical, " Couldn't activate GL context!" );
39033906 return false ;
39043907 }
3908+
3909+ // Turn on vsync
3910+ if (wglSwapIntervalEXT) wglSwapIntervalEXT (1 );
39053911#endif // _SKG_GL_LOAD_WGL
39063912 return 1 ;
39073913}
@@ -5222,6 +5228,7 @@ void skg_swapchain_bind(skg_swapchain_t *swapchain) {
52225228 skg_tex_target_bind (&swapchain->_surface , -1 , 0 );
52235229#elif defined(_SKG_GL_LOAD_WGL)
52245230 wglMakeCurrent ((HDC )swapchain->_hdc , gl_hrc);
5231+ if (wglSwapIntervalEXT) wglSwapIntervalEXT (1 ); // Enable VSync
52255232 skg_tex_target_bind (nullptr , -1 , 0 );
52265233#elif defined(_SKG_GL_LOAD_EGL)
52275234 eglMakeCurrent (egl_display, swapchain->_egl_surface , swapchain->_egl_surface , egl_context);
0 commit comments