From e970d2ee3d1797456fabecb52142476f9b979ede Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 19 Sep 2017 07:18:34 -0400 Subject: [PATCH] Remove FramebufferWidget padding --- include/components.hpp | 3 --- include/widgets.hpp | 1 - src/app/SVGKnob.cpp | 2 -- src/app/SVGPort.cpp | 2 -- src/app/SVGScrew.cpp | 2 -- src/app/SVGSwitch.cpp | 2 -- src/gui.cpp | 3 ++- src/widgets/FramebufferWidget.cpp | 15 +++------------ 8 files changed, 5 insertions(+), 25 deletions(-) diff --git a/include/components.hpp b/include/components.hpp index ab4312ae..48409965 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -361,7 +361,6 @@ struct BefacoSlidePot : SVGSlider { struct PJ301MPort : SVGPort { PJ301MPort() { - padding = Vec(1, 1); background->svg = SVG::load("res/ComponentLibrary/PJ301M.svg"); background->wrap(); box.size = background->box.size; @@ -370,7 +369,6 @@ struct PJ301MPort : SVGPort { struct PJ3410Port : SVGPort { PJ3410Port() { - padding = Vec(1, 1); background->svg = SVG::load("res/ComponentLibrary/PJ3410.svg"); background->wrap(); box.size = background->box.size; @@ -379,7 +377,6 @@ struct PJ3410Port : SVGPort { struct CL1362Port : SVGPort { CL1362Port() { - padding = Vec(1, 1); background->svg = SVG::load("res/ComponentLibrary/CL1362.svg"); background->wrap(); box.size = background->box.size; diff --git a/include/widgets.hpp b/include/widgets.hpp index a4ff0a31..d7411f9f 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -199,7 +199,6 @@ struct FramebufferWidget : virtual Widget { /** A margin in pixels around the children in the framebuffer This prevents cutting the rendered SVG off on the box edges. */ - Vec padding; float oversample = 2.0; /** The root object in the framebuffer scene The FramebufferWidget owns the pointer diff --git a/src/app/SVGKnob.cpp b/src/app/SVGKnob.cpp index 8ff7eb6b..181766e4 100644 --- a/src/app/SVGKnob.cpp +++ b/src/app/SVGKnob.cpp @@ -5,8 +5,6 @@ namespace rack { SVGKnob::SVGKnob() { - padding = Vec(1, 1); - tw = new TransformWidget(); addChild(tw); diff --git a/src/app/SVGPort.cpp b/src/app/SVGPort.cpp index 6c14668c..06343097 100644 --- a/src/app/SVGPort.cpp +++ b/src/app/SVGPort.cpp @@ -5,8 +5,6 @@ namespace rack { SVGPort::SVGPort() { - padding = Vec(1, 1); - background = new SVGWidget(); addChild(background); } diff --git a/src/app/SVGScrew.cpp b/src/app/SVGScrew.cpp index e382d09d..8f7d1073 100644 --- a/src/app/SVGScrew.cpp +++ b/src/app/SVGScrew.cpp @@ -5,8 +5,6 @@ namespace rack { SVGScrew::SVGScrew() { - padding = Vec(1, 1); - sw = new SVGWidget(); addChild(sw); } diff --git a/src/app/SVGSwitch.cpp b/src/app/SVGSwitch.cpp index 86803e6a..6393b88d 100644 --- a/src/app/SVGSwitch.cpp +++ b/src/app/SVGSwitch.cpp @@ -5,8 +5,6 @@ namespace rack { SVGSwitch::SVGSwitch() { - padding = Vec(1, 1); - sw = new SVGWidget(); addChild(sw); } diff --git a/src/gui.cpp b/src/gui.cpp index 9de937cc..dac180f8 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -215,8 +215,9 @@ void guiInit() { // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); + glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); std::string title = gApplicationName + " " + gApplicationVersion; - gWindow = glfwCreateWindow(1000, 750, title.c_str(), NULL, NULL); + gWindow = glfwCreateWindow(640, 480, title.c_str(), NULL, NULL); if (!gWindow) { osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Cannot open window with OpenGL 2.0 renderer. Does your graphics card support OpenGL 2.0? If so, are the latest drivers installed?"); exit(1); diff --git a/src/widgets/FramebufferWidget.cpp b/src/widgets/FramebufferWidget.cpp index c275d9d2..65161788 100644 --- a/src/widgets/FramebufferWidget.cpp +++ b/src/widgets/FramebufferWidget.cpp @@ -38,8 +38,8 @@ void FramebufferWidget::step() { // Render the scene to the framebuffer if dirty if (dirty) { - internal->box.pos = padding.neg(); - internal->box.size = box.size.plus(padding.mult(2)); + internal->box.pos = Vec(0, 0); + internal->box.size = box.size; internal->box.size = Vec(ceilf(internal->box.size.x), ceilf(internal->box.size.y)); Vec fbSize = internal->box.size.mult(gPixelRatio * oversample); // assert(fbSize.isFinite()); @@ -50,14 +50,6 @@ void FramebufferWidget::step() { // Delete old one first to free up GPU memory internal->setFramebuffer(NULL); NVGLUframebuffer *fb = nvgluCreateFramebuffer(gVg, fbSize.x, fbSize.y, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); - - if (!fb) { - char buf[1024]; - snprintf(buf, sizeof(buf), "%f %f, %f %f; %f %f; %p\n", internal->box.pos.x, internal->box.pos.y, internal->box.size.x, internal->box.size.y, fbSize.x, fbSize.y, fb); - if (!osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK_CANCEL, buf)) - exit(0); - } - if (!fb) return; internal->setFramebuffer(fb); @@ -66,10 +58,9 @@ void FramebufferWidget::step() { glViewport(0.0, 0.0, fbSize.x, fbSize.y); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - nvgBeginFrame(gVg, fbSize.x, fbSize.y, gPixelRatio); + nvgBeginFrame(gVg, fbSize.x, fbSize.y, gPixelRatio * oversample); nvgScale(gVg, gPixelRatio * oversample, gPixelRatio * oversample); - nvgTranslate(gVg, padding.x, padding.y); Widget::draw(gVg); nvgEndFrame(gVg);