Browse Source

Remove FrameRateWidget code from Scene. Add debugging to Window::step().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
332b361f87
4 changed files with 20 additions and 20 deletions
  1. +0
    -1
      include/app/Scene.hpp
  2. +2
    -1
      src/app/MenuBar.cpp
  3. +0
    -15
      src/app/Scene.cpp
  4. +18
    -3
      src/window.cpp

+ 0
- 1
include/app/Scene.hpp View File

@@ -18,7 +18,6 @@ struct Scene : widget::OpaqueWidget {
RackWidget* rack;
widget::Widget* menuBar;
widget::Widget* moduleBrowser;
widget::Widget* frameRateWidget;

double lastAutosaveTime = 0.0;
/** The last mouse position in the Scene */


+ 2
- 1
src/app/MenuBar.cpp View File

@@ -1068,6 +1068,7 @@ struct MeterLabel : ui::Label {
void step() override {
double meterAverage = APP->engine->getMeterAverage();
double meterMax = APP->engine->getMeterMax();
// double frameRate = 1.0 / APP->window->getLastFrameDuration();
text = string::f("%.1f%% avg / %.1f%% max", meterAverage * 100, meterMax * 100);
Label::step();
}
@@ -1117,7 +1118,7 @@ struct MenuBar : widget::OpaqueWidget {

meterLabel = new MeterLabel;
meterLabel->box.pos.y = margin;
meterLabel->box.size.x = 160;
meterLabel->box.size.x = 300;
meterLabel->alignment = ui::Label::RIGHT_ALIGNMENT;
meterLabel->color.a = 0.5;
addChild(meterLabel);


+ 0
- 15
src/app/Scene.cpp View File

@@ -19,14 +19,6 @@ namespace rack {
namespace app {


struct FrameRateWidget : widget::TransparentWidget {
void draw(const DrawArgs& args) override {
std::string text = string::f("%.2lf Hz", 1.0 / APP->window->getLastFrameDuration());
bndLabel(args.vg, 0.0, 0.0, INFINITY, INFINITY, -1, text.c_str());
}
};


struct ResizeHandle : widget::OpaqueWidget {
math::Vec size;

@@ -75,11 +67,6 @@ Scene::Scene() {
addChild(tipWindowCreate());
}

// frameRateWidget = new FrameRateWidget;
// frameRateWidget->box.size = math::Vec(80.0, 30.0);
// frameRateWidget->hide();
// addChild(frameRateWidget);

internal->resizeHandle = new ResizeHandle;
internal->resizeHandle->box.size = math::Vec(15, 15);
internal->resizeHandle->hide();
@@ -101,8 +88,6 @@ void Scene::step() {
rackScroll->box.pos.y = menuBar->box.size.y;
}

// frameRateWidget->box.pos.x = box.size.x - frameRateWidget->box.size.x;

internal->resizeHandle->box.pos = box.size.minus(internal->resizeHandle->box.size);

// Resize owned descendants


+ 18
- 3
src/window.cpp View File

@@ -387,10 +387,12 @@ void Window::run() {


void Window::step() {
double frameTime = system::getTime();
double lastFrameTime = internal->frameTime;
internal->frameTime = system::getTime();
internal->lastFrameDuration = internal->frameTime - lastFrameTime;
internal->frameTime = frameTime;
internal->lastFrameDuration = frameTime - lastFrameTime;
// DEBUG("%.2lf Hz", 1.0 / internal->lastFrameDuration);
double t1 = 0.0, t2 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0;

// Make event handlers and step() have a clean NanoVG context
nvgReset(vg);
@@ -446,6 +448,7 @@ void Window::step() {
int winWidth, winHeight;
glfwGetWindowSize(win, &winWidth, &winHeight);
windowRatio = (float)fbWidth / winWidth;
t1 = system::getTime();

if (APP->scene) {
// DEBUG("%f %f %d %d", pixelRatio, windowRatio, fbWidth, winWidth);
@@ -454,6 +457,7 @@ void Window::step() {

// Step scene
APP->scene->step();
t2 = system::getTime();

// Render scene
bool visible = glfwGetWindowAttrib(win, GLFW_VISIBLE) && !glfwGetWindowAttrib(win, GLFW_ICONIFIED);
@@ -467,16 +471,27 @@ void Window::step() {
args.vg = vg;
args.clipBox = APP->scene->box.zeroPos();
APP->scene->draw(args);
t3 = system::getTime();

glViewport(0, 0, fbWidth, fbHeight);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
nvgEndFrame(vg);
t4 = system::getTime();
}
}

glfwSwapBuffers(win);

t5 = system::getTime();

// DEBUG("pre-step %6.1f step %6.1f draw %6.1f nvgEndFrame %6.1f glfwSwapBuffers %6.1f total %6.1f",
// (t1 - frameTime) * 1e3f,
// (t2 - t1) * 1e3f,
// (t3 - t2) * 1e3f,
// (t4 - t2) * 1e3f,
// (t5 - t4) * 1e3f,
// (t5 - frameTime) * 1e3f
// );
internal->frame++;
}



Loading…
Cancel
Save