diff options
author | Arisotura <thetotalworm@gmail.com> | 2019-06-20 16:00:12 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2019-06-20 16:00:12 +0200 |
commit | f59094e033fafc28664700061e2726be70a1568c (patch) | |
tree | a8de2cd99f1510121ed3f70d20ed516bf8b35228 /src/libui_sdl/libui/windows | |
parent | 77bf92a2721867eaa1e2f5571479b3fb0eeac16e (diff) |
OpenGL: disable vsync, atleast under Windows
Diffstat (limited to 'src/libui_sdl/libui/windows')
-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); +} |