OpenGL: disable vsync, atleast under Windows
This commit is contained in:
parent
77bf92a272
commit
f59094e033
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue