From dd199c37b0e29d3e855a5fd578bdaf3d3f31ecd2 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 5 Sep 2017 05:03:58 -0400 Subject: [PATCH] Fix mistake where GLFW buffer was not being flipped each frame --- src/gui.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gui.cpp b/src/gui.cpp index 78af965d..bbcd03b6 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -192,20 +192,24 @@ void renderGui() { glfwGetWindowSize(window, &windowWidth, &windowHeight); gPixelRatio = (float)width / windowWidth; - // Update and render - glViewport(0, 0, width, height); - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - nvgBeginFrame(gVg, width, height, gPixelRatio); - - nvgSave(gVg); - nvgReset(gVg); - nvgScale(gVg, gPixelRatio, gPixelRatio); - gScene->draw(gVg); - nvgRestore(gVg); + bool visible = glfwGetWindowAttrib(window, GLFW_VISIBLE) && !glfwGetWindowAttrib(window, GLFW_ICONIFIED); + if (visible) { + // Update and render + glViewport(0, 0, width, height); + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + nvgBeginFrame(gVg, width, height, gPixelRatio); + + nvgSave(gVg); + nvgReset(gVg); + nvgScale(gVg, gPixelRatio, gPixelRatio); + gScene->draw(gVg); + nvgRestore(gVg); + + nvgEndFrame(gVg); + } - nvgEndFrame(gVg); glfwSwapBuffers(window); } @@ -290,10 +294,7 @@ void guiRun() { } gScene->step(); - bool visible = glfwGetWindowAttrib(window, GLFW_VISIBLE) && !glfwGetWindowAttrib(window, GLFW_ICONIFIED); - if (visible) { - renderGui(); - } + renderGui(); double currTime = glfwGetTime(); // printf("%lf fps\n", 1.0/(currTime - lastTime));