Skip to content

Commit

Permalink
vsync hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
my-tien committed Aug 15, 2014
1 parent f692c7d commit 0abfa48
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
#include <qopengl.h>
#include <QtConcurrent/QtConcurrentRun>

#if defined(Q_OS_WIN)
#include <GL/wglext.h>
#elif defined(Q_OS_LINUX)
#define WINAPI
#include <GL/glx.h>
#include <GL/glxext.h>
#endif

static WINAPI int dummy(int) {
return 0;
}

extern stateInfo *state;

Viewer::Viewer(QObject *parent) :
Expand Down Expand Up @@ -1209,6 +1221,35 @@ void Viewer::run() {
skeletonizer->autoSaveIfElapsed();
window->updateTitlebar();//display changes after filename

static auto disableVsync = [this](){
void (*func)(int) = nullptr;
#if defined(Q_OS_WIN)
func = (void(*)(int))wglGetProcAddress("wglSwapIntervalEXT");
#elif defined(Q_OS_LINUX)
func = (void(*)(int))glXGetProcAddress((const GLubyte *)"glXSwapIntervalSGI");
#endif
if (func != nullptr) {
#if defined(Q_OS_WIN)
return std::bind((PFNWGLSWAPINTERVALEXTPROC)func, 0);
#elif defined(Q_OS_LINUX)
return std::bind((PFNGLXSWAPINTERVALSGIPROC)func, 0);
#endif
} else {
qDebug() << "disabling vsync not available";
return std::bind(&dummy, 0);
}
}();

disableVsync();
vpUpperLeft->updateGL();
disableVsync();
vpLowerLeft->updateGL();
disableVsync();
vpUpperRight->updateGL();
disableVsync();
vpLowerRight->updateGL();
disableVsync();

vpUpperLeft->updateGL();
vpLowerLeft->updateGL();
vpUpperRight->updateGL();
Expand Down

0 comments on commit 0abfa48

Please sign in to comment.