aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2019-06-20 16:00:12 +0200
committerArisotura <thetotalworm@gmail.com>2019-06-20 16:00:12 +0200
commitf59094e033fafc28664700061e2726be70a1568c (patch)
treea8de2cd99f1510121ed3f70d20ed516bf8b35228 /src
parent77bf92a2721867eaa1e2f5571479b3fb0eeac16e (diff)
OpenGL: disable vsync, atleast under Windows
Diffstat (limited to 'src')
-rw-r--r--src/libui_sdl/libui/ui.h1
-rw-r--r--src/libui_sdl/libui/unix/gl.c5
-rw-r--r--src/libui_sdl/libui/windows/gl.cpp35
-rw-r--r--src/libui_sdl/main.cpp1
4 files changed, 42 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h
index e15c127..03aef5d 100644
--- a/src/libui_sdl/libui/ui.h
+++ b/src/libui_sdl/libui/ui.h
@@ -620,6 +620,7 @@ _UI_EXTERN void *uiGLGetProcAddress(const char* proc);
_UI_EXTERN int uiGLGetFramebuffer(uiGLContext* ctx);
_UI_EXTERN float uiGLGetFramebufferScale(uiGLContext* ctx);
_UI_EXTERN void uiGLSwapBuffers(uiGLContext* ctx);
+_UI_EXTERN void uiGLSetVSync(int sync);
_UI_ENUM(uiModifiers) {
diff --git a/src/libui_sdl/libui/unix/gl.c b/src/libui_sdl/libui/unix/gl.c
index e1665ee..e15cf4f 100644
--- a/src/libui_sdl/libui/unix/gl.c
+++ b/src/libui_sdl/libui/unix/gl.c
@@ -193,6 +193,11 @@ void uiGLSwapBuffers(uiGLContext* ctx)
ctx->backbuffer = ctx->backbuffer ? 0 : 1;
}
+void uiGLSetVSync(int sync)
+{
+ // TODO
+}
+
void uiGLMakeContextCurrent(uiGLContext* ctx)
{
if (!ctx)
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);
+}
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 86949eb..693e9e3 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -2417,6 +2417,7 @@ void CreateMainWindow(bool opengl)
if (opengl_good)
{
uiGLMakeContextCurrent(GLContext);
+ uiGLSetVSync(0); // TODO: make configurable?
if (!GLScreen_Init()) opengl_good = false;
if (opengl_good)
{