From 41c66f1d8a392d8ea11d3b2e5790d4e58b062299 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 25 Oct 2017 22:22:04 -0400 Subject: [PATCH] Set SVGPanel oversampling on every frame --- include/app.hpp | 2 +- src/app/SVGPanel.cpp | 6 ++++-- src/gui.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/app.hpp b/include/app.hpp index ff19a64b..8a53f1b6 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -155,7 +155,7 @@ struct Panel : TransparentWidget { }; struct SVGPanel : FramebufferWidget { - SVGPanel(); + void step() override; void setBackground(std::shared_ptr svg); }; diff --git a/src/app/SVGPanel.cpp b/src/app/SVGPanel.cpp index 7c0201bc..178d7d65 100644 --- a/src/app/SVGPanel.cpp +++ b/src/app/SVGPanel.cpp @@ -17,9 +17,11 @@ struct PanelBorder : TransparentWidget { }; -SVGPanel::SVGPanel() { - if (nearf(gPixelRatio, 1.0)) +void SVGPanel::step() { + if (nearf(gPixelRatio, 1.0)) { oversample = 2.0; + } + FramebufferWidget::step(); } void SVGPanel::setBackground(std::shared_ptr svg) { diff --git a/src/gui.cpp b/src/gui.cpp index e8c260c5..d53f2699 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -218,9 +218,6 @@ void errorCallback(int error, const char *description) { void renderGui() { int width, height; glfwGetFramebufferSize(gWindow, &width, &height); - int windowWidth, windowHeight; - glfwGetWindowSize(gWindow, &windowWidth, &windowHeight); - gPixelRatio = (float)width / windowWidth; // Update and render nvgBeginFrame(gVg, width, height, gPixelRatio); @@ -341,6 +338,13 @@ void guiRun() { } glfwSetWindowTitle(gWindow, title.c_str()); + // Get framebuffer size + int width, height; + glfwGetFramebufferSize(gWindow, &width, &height); + int windowWidth, windowHeight; + glfwGetWindowSize(gWindow, &windowWidth, &windowHeight); + gPixelRatio = (float)width / windowWidth; + // Step scene gScene->step();