OpenGL vsync fixes.

This commit is contained in:
rextimmy 2016-12-23 13:59:55 +10:00
parent 38bf2b8175
commit 415f4a046e
7 changed files with 47 additions and 4 deletions

View file

@ -172,12 +172,21 @@ void GFXGLDevice::initGLState()
PlatformGL::setVSync(smDisableVSync ? 0 : 1);
//install vsync callback
Con::NotifyDelegate clbk(this, &GFXGLDevice::vsyncCallback);
Con::addVariableNotify("$pref::Video::disableVerticalSync", clbk);
//OpenGL 3 need a binded VAO for render
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
}
void GFXGLDevice::vsyncCallback()
{
PlatformGL::setVSync(smDisableVSync ? 0 : 1);
}
GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
mAdapterIndex(adapterIndex),
mNeedUpdateVertexAttrib(false),

View file

@ -256,6 +256,8 @@ private:
GFXVertexBuffer* findVolatileVBO(U32 numVerts, const GFXVertexFormat *vertexFormat, U32 vertSize); ///< Returns an existing volatile VB which has >= numVerts and the same vert flags/size, or creates a new VB if necessary
GFXPrimitiveBuffer* findVolatilePBO(U32 numIndices, U32 numPrimitives); ///< Returns an existing volatile PB which has >= numIndices, or creates a new PB if necessary
void vsyncCallback(); ///< Vsync callback
void initGLState(); ///< Guaranteed to be called after all extensions have been loaded, use to init card profiler, shader version, max samplers, etc.

View file

@ -41,7 +41,12 @@ namespace GL
void gglPerformExtensionBinds(void *context)
{
#ifdef TORQUE_OS_WIN
if (!gladLoadWGL(wglGetCurrentDC()))
{
AssertFatal(false, "Unable to load GLAD WGL extensions. Make sure your OpenGL drivers are up to date!");
}
#endif
}
}

View file

@ -30,7 +30,7 @@
#include "tGL.h"
#include <glad/glad_wgl.h>
#define gglHasWExtension(window, EXTENSION) GLAD_WGL_##EXTENSION
#define gglHasWExtension(EXTENSION) GLAD_WGL_##EXTENSION
#endif //TORQUE_OPENGL

View file

@ -269,7 +269,7 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
if (!wglMakeCurrent(hdcGL, tempGLRC))
AssertFatal(false, "Couldn't make temp GL context.");
if( gglHasWExtension(hdcGL, ARB_create_context) )
if( gglHasWExtension( ARB_create_context) )
{
int const create_attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, OGL_MAJOR,