diff options
Diffstat (limited to 'src/libui_sdl/libui/windows/gl.cpp')
-rw-r--r-- | src/libui_sdl/libui/windows/gl.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/windows/gl.cpp b/src/libui_sdl/libui/windows/gl.cpp index c621721..07ef19b 100644 --- a/src/libui_sdl/libui/windows/gl.cpp +++ b/src/libui_sdl/libui/windows/gl.cpp @@ -3,6 +3,7 @@ #include "area.hpp" #include <GL/gl.h> +#include <GL/glext.h> #include <GL/wglext.h> struct uiGLContext @@ -159,3 +160,37 @@ float uiGLGetFramebufferScale(uiGLContext* ctx) // TODO return 1; } + +void uiGLSetVSync(int sync) +{ + static PFNWGLSWAPINTERVALEXTPROC _wglSwapIntervalEXT = NULL; + static bool symloaded = false; + + if (!symloaded) + { + PFNGLGETSTRINGIPROC _glGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); + if (_glGetStringi == NULL) return; + + GLint numext; + glGetIntegerv(GL_NUM_EXTENSIONS, &numext); + + bool hasswapctrl = false; + for (GLint i = 0; i < numext; i++) + { + const char* ext = (const char*)_glGetStringi(GL_EXTENSIONS, i); + if (!stricmp(ext, "WGL_EXT_swap_control")) + { + hasswapctrl = true; + break; + } + } + + if (hasswapctrl) + _wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + + symloaded = true; + } + + if (_wglSwapIntervalEXT) + _wglSwapIntervalEXT(sync); +} |