Browse Source

Fix mistake where GLFW buffer was not being flipped each frame

tags/v0.3.0
Andrew Belt 7 years ago
parent
commit
dd199c37b0
1 changed files with 18 additions and 17 deletions
  1. +18
    -17
      src/gui.cpp

+ 18
- 17
src/gui.cpp View File

@@ -192,20 +192,24 @@ void renderGui() {
glfwGetWindowSize(window, &windowWidth, &windowHeight); glfwGetWindowSize(window, &windowWidth, &windowHeight);
gPixelRatio = (float)width / windowWidth; 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); glfwSwapBuffers(window);
} }


@@ -290,10 +294,7 @@ void guiRun() {
} }
gScene->step(); gScene->step();


bool visible = glfwGetWindowAttrib(window, GLFW_VISIBLE) && !glfwGetWindowAttrib(window, GLFW_ICONIFIED);
if (visible) {
renderGui();
}
renderGui();


double currTime = glfwGetTime(); double currTime = glfwGetTime();
// printf("%lf fps\n", 1.0/(currTime - lastTime)); // printf("%lf fps\n", 1.0/(currTime - lastTime));


Loading…
Cancel
Save