Skip to content
Permalink
Browse files

[desktop] Use VSYNC only if it was explicitly requested, no matter what

the system says
  • Loading branch information
hgy29 committed Jul 3, 2018
1 parent 5e1807e commit 88feef07e8472eb2da26b6301ec88a7edd3181cf
Showing with 6 additions and 0 deletions.
  1. +1 −0 desktop/sources/main.cpp
  2. +1 −0 player/Headers/glcanvas.h
  3. +3 −0 player/Sources/glcanvas.cpp
  4. +1 −0 player/Sources/main.cpp
@@ -82,6 +82,7 @@ int main(int argc, char *argv[]){
QCoreApplication::setApplicationName(Constants::DESK_APPLICATION_NAME);
}

GLCanvas::EnableVSYNC=vsync;
QSurfaceFormat formatGL;
formatGL.setSwapInterval(vsync?(60/fps):0);
formatGL.setStencilBufferSize(8);
@@ -41,6 +41,7 @@ class GLCanvas : public QOpenGLWidget{
//std::set<std::string> accessedResourceFiles;
std::set<std::string> allResourceFiles;
static QString appPackage;
static bool EnableVSYNC;

private slots:
void onTimer();
@@ -195,6 +195,7 @@ static int __mkdir(const char* path) {

static Server* g_server = NULL;
QString GLCanvas::appPackage;
bool GLCanvas::EnableVSYNC=false;

static void printToServer(const char* str, int len, void* data) {
unsigned int size = 1 + ((len < 0) ? strlen(str) : len) + 1;
@@ -388,6 +389,8 @@ void GLCanvas::initializeGL() {
sync_=getSwap();

}
if (!EnableVSYNC) //If VSYNC wasn't requested, use standard timed method
sync_=0;
application_->initialize();
setupApplicationProperties();
}
@@ -63,6 +63,7 @@ int main(int argc, char *argv[]){
QSettings settings(Constants::SETTINGS_FOLDER + "/" + Constants::PLAYER_SETTINGS_FILE, QSettings::IniFormat);
int fps=settings.value("fps",60).toInt();
int vsync=settings.value("vsync",0).toInt();
GLCanvas::EnableVSYNC=vsync;
QSurfaceFormat formatGL;
formatGL.setSwapInterval(vsync?(60/fps):0);
formatGL.setStencilBufferSize(8);

0 comments on commit 88feef0

Please sign in to comment.
You can’t perform that action at this time.