Browse Source

Render GUI only when window is visible

tags/v0.3.0
Andrew Belt 7 years ago
parent
commit
f703aaac9d
4 changed files with 11 additions and 5 deletions
  1. +2
    -2
      src/app/RackWidget.cpp
  2. +1
    -0
      src/app/WireWidget.cpp
  3. +3
    -2
      src/engine.cpp
  4. +5
    -1
      src/gui.cpp

+ 2
- 2
src/app/RackWidget.cpp View File

@@ -311,9 +311,9 @@ void RackWidget::draw(NVGcontext *vg) {
// Rails
// TODO Put this in a framebuffer cache and tile
const float railHeight = 15;
nvgFillColor(vg, nvgRGBf(0.8, 0.8, 0.8));
nvgFillColor(vg, nvgRGBf(0.85, 0.85, 0.85));
nvgStrokeWidth(vg, 1.0);
nvgStrokeColor(vg, nvgRGBf(0.6, 0.6, 0.6));
nvgStrokeColor(vg, nvgRGBf(0.7, 0.7, 0.7));
float holeRadius = 3.5;
for (float railY = 0; railY < box.size.y; railY += rackGridSize.y) {
// Top rail


+ 1
- 0
src/app/WireWidget.cpp View File

@@ -160,6 +160,7 @@ void WireWidget::draw(NVGcontext *vg) {
}

void WireWidget::drawPlugs(NVGcontext *vg) {
// TODO Figure out a way to draw plugs first and wires last, and cut the plug portion of the wire off.
}




+ 3
- 2
src/engine.cpp View File

@@ -98,9 +98,10 @@ static void engineRun() {
}
}
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::nanoseconds((long) (0.5 * 1e9 * stepSize / gSampleRate)) - (end - start);
auto duration = std::chrono::nanoseconds((long) (0.10 * 1e9 * stepSize / gSampleRate)) - (end - start);
// Avoid pegging the CPU at 100% when there are no "blocking" modules like AudioInterface, but still step audio at a reasonable rate
// std::this_thread::sleep_for(duration);
// if (duration > 0)
// std::this_thread::sleep_for(duration);
}
}



+ 5
- 1
src/gui.cpp View File

@@ -271,7 +271,11 @@ void guiRun() {
cursorPosCallback(window, xpos, ypos);
}
gScene->step();
renderGui();

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

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


Loading…
Cancel
Save