From b410d8dc86933785822659ab51ace6aa222afc1f Mon Sep 17 00:00:00 2001 From: bsp2 Date: Thu, 25 Oct 2018 23:06:10 +0200 Subject: [PATCH] add "fbo" config option (settings.json) (for VirtualBox VM) --- include/global_ui.hpp | 5 +++++ src/settings.cpp | 21 ++++++++++++++++++--- src/widgets/FramebufferWidget.cpp | 13 ++++++++++--- vst2_bin/settings.json | 3 ++- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/include/global_ui.hpp b/include/global_ui.hpp index e13e516b..2d9c057b 100644 --- a/include/global_ui.hpp +++ b/include/global_ui.hpp @@ -104,6 +104,8 @@ struct GlobalUI { int placeholder_framecount; } param_info; + bool b_fbo; // usually true. set to false when using the VirtualBox GL driver. + int pending_swap_interval; // -1=none, 1=vsync on, 0=vsync off void init(void) { @@ -152,6 +154,9 @@ struct GlobalUI { param_info.tf_value = NULL; param_info.b_lock = false; param_info.placeholder_framecount = 0; + + b_fbo = true; + pending_swap_interval = -1; } }; diff --git a/src/settings.cpp b/src/settings.cpp index 41c6ad62..7518099d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -82,6 +82,10 @@ static json_t *settingsToJson() { json_t *vsyncJ = json_boolean(vsync); json_object_set_new(rootJ, "vsync", vsyncJ); + // fbo + json_t *fboJ = json_boolean(!global_ui->b_fbo); + json_object_set_new(rootJ, "fbo", fboJ); + // touchInput int touchInput = lglw_touchinput_get(global_ui->window.lglw); json_t *touchInputJ = json_boolean(touchInput); @@ -252,12 +256,23 @@ static void settingsFromJson(json_t *rootJ, bool bWindowSizeOnly) { json_t *vsyncJ = json_object_get(rootJ, "vsync"); if (vsyncJ) { - lglw_glcontext_push(global_ui->window.lglw); - lglw_swap_interval_set(global_ui->window.lglw, json_is_true(vsyncJ)); - lglw_glcontext_pop(global_ui->window.lglw); + // lglw_glcontext_push(global_ui->window.lglw); + // lglw_swap_interval_set(global_ui->window.lglw, json_is_true(vsyncJ); + // lglw_glcontext_pop(global_ui->window.lglw); + + // postpone until first vst2_editor_redraw() call (see window.cpp) + // (note) on Linux we need a drawable to set the swap interval + global_ui->pending_swap_interval = json_is_true(vsyncJ); } } + // fbo support (not working with VirtualBox GL driver!) + json_t *fboJ = json_object_get(rootJ, "fbo"); + if (fboJ) + { + global_ui->b_fbo = json_is_true(fboJ); + } + // allowCursorLock json_t *allowCursorLockJ = json_object_get(rootJ, "allowCursorLock"); if (allowCursorLockJ) diff --git a/src/widgets/FramebufferWidget.cpp b/src/widgets/FramebufferWidget.cpp index 1f31a155..81d092ed 100644 --- a/src/widgets/FramebufferWidget.cpp +++ b/src/widgets/FramebufferWidget.cpp @@ -36,12 +36,19 @@ FramebufferWidget::~FramebufferWidget() { void FramebufferWidget::draw(NVGcontext *vg) { // Bypass framebuffer rendering entirely + // printf("xxx FramebufferWidget::draw\n"); #ifdef RACK_PLUGIN_SHARED + bool bFBO = false; +#else + bool bFBO = global_ui->b_fbo; +#endif // RACK_PLUGIN_SHARED // (note) FBO path crashes when plugin is a DLL (!) // (the glGenFramebuffers() call in nvgluCreateFramebuffer() to be precise) - Widget::draw(vg); - return; -#endif // RACK_PLUGIN_SHARED + if(!bFBO) + { + Widget::draw(vg); + return; + } // printf("xxx FramebufferWidget::draw: ENTER vg=%p\n", vg); // printf("xxx FramebufferWidget::draw: GetCurrentThreadId=%d\n", GetCurrentThreadId()); diff --git a/vst2_bin/settings.json b/vst2_bin/settings.json index ed515ca7..e82ab5f9 100644 --- a/vst2_bin/settings.json +++ b/vst2_bin/settings.json @@ -13,6 +13,7 @@ "zoom": 1.0, "refreshRate": 30, "vsync": true, + "fbo": true, "touchInput": false, "touchKbd": false, "oversampleFactor": 1.0, @@ -265,4 +266,4 @@ }, "powerMeter": false, "checkVersion": true -} \ No newline at end of file +}