From 75fde6c407109039c3b39ac5d92ccdc7038483a9 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 4 Jan 2022 12:08:14 +0000 Subject: [PATCH] Fixing ProM GL2/3 conflicts --- .github/workflows/build.yml | 2 +- dpf/dgl/OpenGL.hpp | 8 ++++++++ dpf/dgl/src/NanoVG.cpp | 2 +- dpf/dgl/src/OpenGL.cpp | 16 ++++++++++++++++ plugins/ProM/DistrhoUIProM.cpp | 18 ++++++++++++------ plugins/ProM/DistrhoUIProM.hpp | 11 ++++++++++- plugins/ProM/ResizeHandle.hpp | 2 ++ 7 files changed, 50 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f04e2e..53cc639 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -175,7 +175,7 @@ jobs: !bin/vst3 win32: - runs-on: ubuntu-20.04 + runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 with: diff --git a/dpf/dgl/OpenGL.hpp b/dpf/dgl/OpenGL.hpp index 67a0ddd..629d831 100644 --- a/dpf/dgl/OpenGL.hpp +++ b/dpf/dgl/OpenGL.hpp @@ -129,7 +129,11 @@ ImageFormat asDISTRHOImageFormat(const GLenum format) { switch (format) { +#ifdef DGL_USE_OPENGL3 + case GL_RED: +#else case GL_LUMINANCE: +#endif return kImageFormatGrayscale; case GL_BGR: return kImageFormatBGR; @@ -152,7 +156,11 @@ GLenum asOpenGLImageFormat(const ImageFormat format) case kImageFormatNull: break; case kImageFormatGrayscale: +#ifdef DGL_USE_OPENGL3 + return GL_RED; +#else return GL_LUMINANCE; +#endif case kImageFormatBGR: return GL_BGR; case kImageFormatBGRA: diff --git a/dpf/dgl/src/NanoVG.cpp b/dpf/dgl/src/NanoVG.cpp index 772391b..cb78fad 100644 --- a/dpf/dgl/src/NanoVG.cpp +++ b/dpf/dgl/src/NanoVG.cpp @@ -88,7 +88,7 @@ DGL_EXT(PFNGLUNIFORMBLOCKBINDINGPROC, glUniformBlockBinding) # define NANOVG_GL2_IMPLEMENTATION #endif -#if defined(DISTRHO_OS_MAC) && defined(NANOVG_GL3_IMPLEMENTATION) +#if defined(DISTRHO_OS_MAC) && defined(NANOVG_GL2_IMPLEMENTATION) # define glBindVertexArray glBindVertexArrayAPPLE # define glDeleteVertexArrays glDeleteVertexArraysAPPLE # define glGenVertexArrays glGenVertexArraysAPPLE diff --git a/dpf/dgl/src/OpenGL.cpp b/dpf/dgl/src/OpenGL.cpp index eb619c3..145c315 100644 --- a/dpf/dgl/src/OpenGL.cpp +++ b/dpf/dgl/src/OpenGL.cpp @@ -38,10 +38,12 @@ START_NAMESPACE_DGL void Color::setFor(const GraphicsContext&, const bool includeAlpha) { +#ifndef DGL_USE_OPENGL3 if (includeAlpha) glColor4f(red, green, blue, alpha); else glColor3f(red, green, blue); +#endif } // ----------------------------------------------------------------------- @@ -52,6 +54,7 @@ static void drawLine(const Point& posStart, const Point& posEnd) { DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,); +#ifndef DGL_USE_OPENGL3 glBegin(GL_LINES); { @@ -60,6 +63,7 @@ static void drawLine(const Point& posStart, const Point& posEnd) } glEnd(); +#endif } template @@ -102,6 +106,7 @@ static void drawCircle(const Point& pos, const T origy = pos.getY(); double t, x = size, y = 0.0; +#ifndef DGL_USE_OPENGL3 glBegin(outline ? GL_LINE_LOOP : GL_POLYGON); for (uint i=0; i& pos, } glEnd(); +#endif } template @@ -162,6 +168,7 @@ static void drawTriangle(const Point& pos1, { DISTRHO_SAFE_ASSERT_RETURN(pos1 != pos2 && pos1 != pos3,); +#ifndef DGL_USE_OPENGL3 glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES); { @@ -171,6 +178,7 @@ static void drawTriangle(const Point& pos1, } glEnd(); +#endif } template @@ -216,6 +224,7 @@ static void drawRectangle(const Rectangle& rect, const bool outline) { DISTRHO_SAFE_ASSERT_RETURN(rect.isValid(),); +#ifndef DGL_USE_OPENGL3 glBegin(outline ? GL_LINE_LOOP : GL_QUADS); { @@ -238,6 +247,7 @@ static void drawRectangle(const Rectangle& rect, const bool outline) } glEnd(); +#endif } template @@ -316,11 +326,14 @@ static void drawOpenGLImage(const OpenGLImage& image, const Point& pos, con setupCalled = true; } +#ifndef DGL_USE_OPENGL3 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); +#endif glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textureId); +#ifndef DGL_USE_OPENGL3 glBegin(GL_QUADS); { @@ -343,6 +356,7 @@ static void drawOpenGLImage(const OpenGLImage& image, const Point& pos, con } glEnd(); +#endif glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); @@ -528,6 +542,7 @@ void ImageBaseKnob::onDisplay() pData->isReady = true; } +#ifndef DGL_USE_OPENGL3 const int w = static_cast(getWidth()); const int h = static_cast(getHeight()); @@ -549,6 +564,7 @@ void ImageBaseKnob::onDisplay() { Rectangle(0, 0, w, h).draw(context); } +#endif glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); diff --git a/plugins/ProM/DistrhoUIProM.cpp b/plugins/ProM/DistrhoUIProM.cpp index ff0a137..fc2cc04 100644 --- a/plugins/ProM/DistrhoUIProM.cpp +++ b/plugins/ProM/DistrhoUIProM.cpp @@ -93,17 +93,23 @@ static String getCurrentExecutableDataDir() DistrhoUIProM::DistrhoUIProM() : UI(512, 512), - fPM(nullptr), - fResizeHandle(this) + fPM(nullptr) +#ifndef DGL_USE_OPENGL3 + , fResizeHandle(this) +#endif { - // const double scaleFactor = getScaleFactor(); - // if (d_isNotZero(scaleFactor)) - // setSize(512*scaleFactor, 512*scaleFactor) - setGeometryConstraints(256, 256, true); + const double scaleFactor = getScaleFactor(); + + if (d_isNotZero(scaleFactor)) + setSize(512*scaleFactor, 512*scaleFactor); + + setGeometryConstraints(256*scaleFactor, 256*scaleFactor, true); // no need to show resize handle if window is user-resizable +#ifndef DGL_USE_OPENGL3 // if (isResizable()) // fResizeHandle.hide(); +#endif } DistrhoUIProM::~DistrhoUIProM() diff --git a/plugins/ProM/DistrhoUIProM.hpp b/plugins/ProM/DistrhoUIProM.hpp index 98e1ba6..41c1803 100644 --- a/plugins/ProM/DistrhoUIProM.hpp +++ b/plugins/ProM/DistrhoUIProM.hpp @@ -17,8 +17,15 @@ #ifndef DISTRHO_UI_PROM_HPP_INCLUDED #define DISTRHO_UI_PROM_HPP_INCLUDED +#ifdef DISTRHO_OS_MAC +# define DGL_USE_OPENGL3 +#endif + #include "DistrhoUI.hpp" -#include "ResizeHandle.hpp" + +#ifndef DGL_USE_OPENGL3 +# include "ResizeHandle.hpp" +#endif class projectM; @@ -52,7 +59,9 @@ protected: private: ScopedPointer fPM; +#ifndef DGL_USE_OPENGL3 ResizeHandle fResizeHandle; +#endif DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIProM) }; diff --git a/plugins/ProM/ResizeHandle.hpp b/plugins/ProM/ResizeHandle.hpp index 9729f8e..9782dfe 100644 --- a/plugins/ProM/ResizeHandle.hpp +++ b/plugins/ProM/ResizeHandle.hpp @@ -58,7 +58,9 @@ protected: #ifdef DGL_OPENGL glUseProgram(0); +# ifndef DGL_USE_OPENGL3 glMatrixMode(GL_MODELVIEW); +# endif #endif // draw white lines, 1px wide