diff --git a/Makefile b/Makefile index 49a3382..b8ad38a 100644 --- a/Makefile +++ b/Makefile @@ -6,27 +6,33 @@ include dpf/Makefile.base.mk -all: dgl plugins gen +all: dgl plugins gen resources # -------------------------------------------------------------- dgl: - $(MAKE) SKIP_NANOVG=true -C dpf/dgl opengl + $(MAKE) USE_NANOVG_FBO=true USE_RGBA=true -C dpf/dgl opengl plugins: dgl $(MAKE) all -C plugins/Cardinal ifneq ($(CROSS_COMPILING),true) -gen: plugins dpf/utils/lv2_ttl_generator +gen: plugins resources dpf/utils/lv2_ttl_generator @$(CURDIR)/dpf/utils/generate-ttl.sh ifeq ($(MACOS),true) @$(CURDIR)/dpf/utils/generate-vst-bundles.sh endif +resources: bin/Cardinal.lv2/res + +bin/Cardinal.lv2/res: plugins + ln -sf $(CURDIR)/plugins/Cardinal/Rack/res bin/Cardinal.lv2/res + dpf/utils/lv2_ttl_generator: $(MAKE) -C dpf/utils/lv2-ttl-generator else gen: +resources: endif # -------------------------------------------------------------- diff --git a/dpf b/dpf index c17c260..d8f66c1 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit c17c260d08613ab46e13dc578104c74b5713a435 +Subproject commit d8f66c1e06cafedf000fe75afcf67b96b3efbc6c diff --git a/plugins/Cardinal/CardinalPlugin.cpp b/plugins/Cardinal/CardinalPlugin.cpp index d04ad0b..be30991 100644 --- a/plugins/Cardinal/CardinalPlugin.cpp +++ b/plugins/Cardinal/CardinalPlugin.cpp @@ -32,6 +32,7 @@ #include +#undef DEBUG #include "DistrhoPlugin.hpp" START_NAMESPACE_DISTRHO @@ -124,6 +125,9 @@ struct Initializer { midi::destroy(); audio::destroy(); plugin::destroy(); +#ifndef DPF_AS_GLFW + gamepad::destroy(); +#endif INFO("Destroying logger"); logger::destroy(); } diff --git a/plugins/Cardinal/CardinalUI.cpp b/plugins/Cardinal/CardinalUI.cpp index 1adfda6..e020dac 100644 --- a/plugins/Cardinal/CardinalUI.cpp +++ b/plugins/Cardinal/CardinalUI.cpp @@ -24,6 +24,7 @@ #include #include +#undef DEBUG #include "DistrhoUI.hpp" #include "ResizeHandle.hpp" @@ -96,7 +97,7 @@ public: License, or (at your option) any later version. */ // Initialize context - INFO("Initializing context"); + d_stdout("UI context ptr %p", NanoVG::getContext()); #ifdef DPF_AS_GLFW window::lastUI = this; #endif @@ -125,7 +126,7 @@ public: contextSet(NULL); } - void onDisplay() override + void onNanoDisplay() override { APP->window->step(); } @@ -191,6 +192,12 @@ protected: case 3: button = GLFW_MOUSE_BUTTON_RIGHT; break; +// case 4: +// button = GLFW_MOUSE_WHEELUP; +// break; +// case 5: +// button = GLFW_MOUSE_WHEELDOWN; +// break; default: button = 0; break; diff --git a/plugins/Cardinal/DistrhoPluginInfo.h b/plugins/Cardinal/DistrhoPluginInfo.h index 7b4a845..0ff5612 100644 --- a/plugins/Cardinal/DistrhoPluginInfo.h +++ b/plugins/Cardinal/DistrhoPluginInfo.h @@ -30,7 +30,7 @@ // #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer" // #define DISTRHO_PLUGIN_HAS_EMBED_UI 1 // #define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 1 -// #define DISTRHO_UI_USE_NANOVG 1 +#define DISTRHO_UI_USE_NANOVG 1 #define DISTRHO_UI_USER_RESIZABLE 0 #define DPF_AS_GLFW 1 diff --git a/plugins/Cardinal/Makefile b/plugins/Cardinal/Makefile index 20f83d1..7dca47e 100644 --- a/plugins/Cardinal/Makefile +++ b/plugins/Cardinal/Makefile @@ -16,14 +16,16 @@ FILES_DSP = \ CardinalPlugin.cpp FILES_UI = \ - CardinalUI.cpp \ - Window.cpp + CardinalUI.cpp + +FILES_UI += dep.cpp +FILES_UI += Window.cpp # -------------------------------------------------------------- # Import base definitions # UI_TYPE = external -SKIP_NANOVG = true +USE_NANOVG_FBO = true include ../../dpf/Makefile.base.mk # -------------------------------------------------------------- @@ -33,7 +35,7 @@ FILES_DSP += Rack/dep/pffft/pffft.c FILES_DSP += Rack/dep/pffft/fftpack.c FILES_UI += Rack/dep/oui-blendish/blendish.c -FILES_UI += Rack/dep/nanovg/src/nanovg.c +# FILES_UI += Rack/dep/nanovg/src/nanovg.c # FIXME dont use this FILES_UI += Rack/dep/osdialog/osdialog.c @@ -47,7 +49,7 @@ endif FILES_DSP += $(wildcard Rack/src/*.c) FILES_DSP += $(wildcard Rack/src/*/*.c) -FILES_DSP += $(filter-out Rack/src/discord.cpp Rack/src/gamepad.cpp Rack/src/network.cpp Rack/src/rtaudio.cpp Rack/src/rtmidi.cpp, $(wildcard Rack/src/*.cpp)) +FILES_DSP += $(filter-out Rack/src/dep.cpp Rack/src/discord.cpp Rack/src/gamepad.cpp Rack/src/network.cpp Rack/src/rtaudio.cpp Rack/src/rtmidi.cpp, $(wildcard Rack/src/*.cpp)) FILES_DSP += $(filter-out Rack/src/window/Window.cpp, $(wildcard Rack/src/*/*.cpp)) EXTRA_LIBS += Rack/dep/lib/libjansson.a @@ -93,15 +95,15 @@ Rack/dep/lib/libcrypto.a: Rack/dep/lib/libssl.a # Extra flags for VCV stuff BASE_FLAGS += -D_APP_VERSION=2.git.0 -# BASE_FLAGS += -I$(DPF_PATH)/dgl/src/nanovg +BASE_FLAGS += -I$(DPF_PATH)/dgl/src/nanovg BASE_FLAGS += -IRack/include BASE_FLAGS += -IRack/dep/include BASE_FLAGS += -IRack/dep/filesystem/include BASE_FLAGS += -IRack/dep/fuzzysearchdatabase/src -BASE_FLAGS += -IRack/dep/glew-2.1.0/include -BASE_FLAGS += -IRack/dep/glfw/deps +# BASE_FLAGS += -IRack/dep/glew-2.1.0/include +# BASE_FLAGS += -IRack/dep/glfw/deps BASE_FLAGS += -IRack/dep/glfw/include -BASE_FLAGS += -IRack/dep/nanovg/src +# BASE_FLAGS += -IRack/dep/nanovg/src BASE_FLAGS += -IRack/dep/nanosvg/src BASE_FLAGS += -IRack/dep/osdialog BASE_FLAGS += -IRack/dep/oui-blendish diff --git a/plugins/Cardinal/ResizeHandle.hpp b/plugins/Cardinal/ResizeHandle.hpp index da5a4f7..3753b3d 100644 --- a/plugins/Cardinal/ResizeHandle.hpp +++ b/plugins/Cardinal/ResizeHandle.hpp @@ -58,7 +58,7 @@ protected: #ifdef DGL_OPENGL // glUseProgram(0); - // glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); #endif // draw white lines, 1px wide diff --git a/plugins/Cardinal/Window.cpp b/plugins/Cardinal/Window.cpp index 1d3cc6a..e3b8121 100644 --- a/plugins/Cardinal/Window.cpp +++ b/plugins/Cardinal/Window.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -16,6 +15,7 @@ #include // used in Window::screenshot #include // used in Window::screenshot +#undef DEBUG #include "DistrhoUI.hpp" namespace rack { @@ -94,14 +94,6 @@ Window::Window() { int err; - // Set up GLEW - glewExperimental = GL_TRUE; - err = glewInit(); - if (err != GLEW_OK) { - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize GLEW. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); - exit(1); - } - const GLubyte* vendor = glGetString(GL_VENDOR); const GLubyte* renderer = glGetString(GL_RENDERER); const GLubyte* version = glGetString(GL_VERSION); @@ -109,24 +101,9 @@ Window::Window() { INFO("OpenGL: %s", version); INFO("UI pointer: %p", lastUI); - // GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here. - glGetError(); - - // Set up NanoVG - int nvgFlags = NVG_ANTIALIAS; -#if defined NANOVG_GL2 - vg = nvgCreateGL2(nvgFlags); - fbVg = nvgCreateSharedGL2(vg, nvgFlags); -#elif defined NANOVG_GL3 - vg = nvgCreateGL3(nvgFlags); -#elif defined NANOVG_GLES2 - vg = nvgCreateGLES2(nvgFlags); -#endif - if (!vg) { - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize NanoVG. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); - exit(1); - } - d_stderr2("framebuffer is %p", fbVg); + vg = lastUI->getContext(); + INFO("NanoVG context: %p", vg); +// fbVg = nvgCreateSharedGL2(vg, nvgFlags); // Load default Blendish font uiFont = loadFont(asset::system("res/fonts/DejaVuSans.ttf")); @@ -149,17 +126,6 @@ Window::~Window() { internal->fontCache.clear(); internal->imageCache.clear(); - // nvgDeleteClone(fbVg); - -#if defined NANOVG_GL2 - nvgDeleteGL2(vg); - nvgDeleteGL2(fbVg); -#elif defined NANOVG_GL3 - nvgDeleteGL3(vg); -#elif defined NANOVG_GLES2 - nvgDeleteGLES2(vg); -#endif - delete internal; } @@ -239,7 +205,7 @@ void Window::step() { bool visible = true; if (visible) { // Update and render - nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio); +// nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio); nvgScale(vg, pixelRatio, pixelRatio); // Draw scene @@ -252,7 +218,7 @@ void Window::step() { 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); +// nvgEndFrame(vg); t4 = system::getTime(); } }