Browse Source

Update DPF

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.5
falkTX 3 years ago
parent
commit
5064afd9ac
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
18 changed files with 493 additions and 354 deletions
  1. +55
    -41
      .github/workflows/build.yml
  2. +1
    -12
      Makefile
  3. +32
    -0
      dpf/Makefile.base.mk
  4. +15
    -0
      dpf/Makefile.plugins.mk
  5. +36
    -20
      dpf/dgl/Makefile
  6. +83
    -10
      dpf/dgl/src/OpenGL.cpp
  7. +147
    -143
      dpf/dgl/src/nanovg/fontstash.h
  8. +2
    -2
      dpf/distrho/src/DistrhoPluginVST2.cpp
  9. +1
    -0
      dpf/distrho/src/DistrhoUIInternal.hpp
  10. +7
    -2
      dpf/distrho/src/DistrhoUIVST3.cpp
  11. +1
    -1
      plugins/Nekobi/DistrhoPluginInfo.h
  12. +1
    -1
      plugins/Nekobi/Makefile
  13. +26
    -78
      plugins/ProM/DistrhoUIProM.cpp
  14. +2
    -11
      plugins/ProM/DistrhoUIProM.hpp
  15. +3
    -0
      plugins/ProM/Makefile
  16. +37
    -17
      plugins/ProM/ResizeHandle.hpp
  17. +7
    -2
      plugins/glBars/DistrhoUIGLBars.cpp
  18. +37
    -14
      plugins/glBars/ResizeHandle.hpp

+ 55
- 41
.github/workflows/build.yml View File

@@ -13,33 +13,34 @@ env:

jobs:
linux-arm64:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Fix GitHub's mess
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture arm64
sudo sed -i "s/deb http/deb [arch=amd64] http/" /etc/apt/sources.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
sudo apt-get update -qq
sudo apt-get install -yq g++-aarch64-linux-gnu libasound2-dev:arm64 libcairo2-dev:arm64 libgl1-mesa-dev:arm64 liblo-dev:arm64 libpulse-dev:arm64 libx11-dev:arm64 libxcursor-dev:arm64 libxext-dev:arm64 libxrandr-dev:arm64 qemu-user-static
# fix broken Ubuntu packages missing pkg-config file in multi-arch package
sudo apt-get install -yq libasound2-dev libgl1-mesa-dev liblo-dev libpulse-dev libxcursor-dev libxrandr-dev
sudo ln -s /usr/lib/aarch64-linux-gnu/liblo.so.7 /usr/lib/aarch64-linux-gnu/liblo.so
sudo cp /usr/lib/x86_64-linux-gnu/pkgconfig/liblo.pc /usr/lib/aarch64-linux-gnu/pkgconfig/liblo.pc
sudo sed -i "s/x86_64-linux-gnu/aarch64-linux-gnu/" /usr/lib/aarch64-linux-gnu/pkgconfig/liblo.pc
sudo apt-get install -yqq g++-aarch64-linux-gnu libasound2-dev:arm64 libcairo2-dev:arm64 libdbus-1-dev:arm64 libgl1-mesa-dev:arm64 liblo-dev:arm64 libpulse-dev:arm64 libx11-dev:arm64 libxcursor-dev:arm64 libxext-dev:arm64 libxrandr-dev:arm64 qemu-user-static
- name: Build linux arm64 cross-compiled
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
LDFLAGS: -static-libgcc -static-libstdc++
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
@@ -50,33 +51,34 @@ jobs:
bin/*

linux-armhf:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Fix GitHub's mess
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture armhf
sudo sed -i "s/deb http/deb [arch=amd64] http/" /etc/apt/sources.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
sudo apt-get update -qq
sudo apt-get install -yq g++-arm-linux-gnueabihf libasound2-dev:armhf libcairo2-dev:armhf libgl1-mesa-dev:armhf liblo-dev:armhf libpulse-dev:armhf libx11-dev:armhf libxcursor-dev:armhf libxext-dev:armhf libxrandr-dev:armhf qemu-user-static
# fix broken Ubuntu packages missing pkg-config file in multi-arch package
sudo apt-get install -yq libasound2-dev libgl1-mesa-dev liblo-dev libpulse-dev libxcursor-dev libxrandr-dev
sudo ln -s /usr/lib/arm-linux-gnueabihf/liblo.so.7 /usr/lib/arm-linux-gnueabihf/liblo.so
sudo cp /usr/lib/x86_64-linux-gnu/pkgconfig/liblo.pc /usr/lib/arm-linux-gnueabihf/pkgconfig/liblo.pc
sudo sed -i "s/x86_64-linux-gnu/arm-linux-gnueabihf/" /usr/lib/arm-linux-gnueabihf/pkgconfig/liblo.pc
sudo apt-get install -yqq g++-arm-linux-gnueabihf libasound2-dev:armhf libcairo2-dev:armhf libdbus-1-dev:armhf libgl1-mesa-dev:armhf liblo-dev:armhf libpulse-dev:armhf libx11-dev:armhf libxcursor-dev:armhf libxext-dev:armhf libxrandr-dev:armhf qemu-user-static
- name: Build linux armhf cross-compiled
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
LDFLAGS: -static-libgcc -static-libstdc++
PKG_CONFIG_PATH: /usr/lib/arm-linux-gnueabihf/pkgconfig
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
@@ -86,37 +88,44 @@ jobs:
path: |
bin/*

linux-x86:
runs-on: ubuntu-18.04
linux-i686:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Fix GitHub's mess
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -qq
sudo apt-get install -yq g++-multilib libasound2-dev:i386 libcairo2-dev:i386 libgl1-mesa-dev:i386 liblo-dev:i386 libpulse-dev:i386 libx11-dev:i386 libxcursor-dev:i386 libxext-dev:i386 libxrandr-dev:i386
- name: Build linux x86
sudo apt-get install -yqq g++-i686-linux-gnu libasound2-dev:i386 libcairo2-dev:i386 libdbus-1-dev:i386 libgl1-mesa-dev:i386 liblo-dev:i386 libpulse-dev:i386 libx11-dev:i386 libxcursor-dev:i386 libxext-dev:i386 libxrandr-dev:i386
- name: Build linux i686
env:
CC: i686-linux-gnu-gcc
CXX: i686-linux-gnu-g++
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32 -static-libgcc -static-libstdc++
PKG_CONFIG_PATH: /usr/lib/i386-linux-gnu/pkgconfig
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
- uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}-linux-x86-${{ github.event.pull_request.number || steps.slug.outputs.sha8 }}
name: ${{ github.event.repository.name }}-linux-i686-${{ github.event.pull_request.number || steps.slug.outputs.sha8 }}
path: |
bin/*

linux-x86_64:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
@@ -124,13 +133,13 @@ jobs:
- name: Set up dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yq libasound2-dev libcairo2-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
sudo apt-get install -yqq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
- name: Build linux x86_64
env:
LDFLAGS: -static-libgcc -static-libstdc++
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
@@ -157,7 +166,7 @@ jobs:
LDFLAGS: -arch x86_64 -arch arm64 -mmacosx-version-min=10.12
run: |
make features
make NOOPT=true -j $(sysctl -n hw.logicalcpu)
make NOOPT=true WITH_LTO=true -j $(sysctl -n hw.logicalcpu)
./dpf/utils/package-osx-bundles.sh
- name: Set sha8
id: slug
@@ -175,16 +184,21 @@ jobs:
!bin/vst3

win32:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Fix GitHub's mess
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -qq
sudo apt-get install -yq binutils-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64 wine-stable:i386
sudo apt-get install -yqq binutils-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64 wine-stable:i386
- name: Build win32 cross-compiled
env:
CC: i686-w64-mingw32-gcc
@@ -194,7 +208,7 @@ jobs:
WINEDEBUG: "-all"
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
@@ -215,7 +229,7 @@ jobs:
- name: Set up dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yq binutils-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64 wine-stable
sudo apt-get install -yqq binutils-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64 wine-stable
- name: Build win64 cross-compiled
env:
CC: x86_64-w64-mingw32-gcc
@@ -225,7 +239,7 @@ jobs:
WINEDEBUG: "-all"
run: |
make features
make -j $(nproc)
make WITH_LTO=true -j $(nproc)
- name: Set sha8
id: slug
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
@@ -250,9 +264,9 @@ jobs:
sudo dpkg -i kxstudio-repos_10.0.3_all.deb
sudo apt-get update -qq
# build-deps
sudo apt-get install -yq libasound2-dev libcairo2-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
sudo apt-get install -yqq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
# runtime testing
sudo apt-get install -yq carla-git lilv-utils lv2-dev lv2lint valgrind
sudo apt-get install -yqq carla-git lilv-utils lv2-dev lv2lint valgrind
- name: Build plugins
env:
CFLAGS: -g
@@ -313,14 +327,14 @@ jobs:
done
- name: Test VST2 plugins
run: |
for p in $(ls bin/ | grep vst.so); do \
for p in $(find bin/ | grep -e vst.so -e '.*\.vst/.*\.so'); do \
env CARLA_BRIDGE_DUMMY=1 CARLA_BRIDGE_TESTING=native \
valgrind \
--error-exitcode=255 \
--leak-check=full \
--track-origins=yes \
--suppressions=./dpf/utils/valgrind-dpf.supp \
/usr/lib/carla/carla-bridge-native vst2 ./bin/${p} "" 1>/dev/null; \
/usr/lib/carla/carla-bridge-native vst2 ./${p} "" 1>/dev/null; \
done
- name: Test VST3 plugins
run: |


+ 1
- 12
Makefile View File

@@ -13,11 +13,6 @@ all: dgl plugins resources gen
PREFIX ?= /usr/local
DESTDIR ?=

# --------------------------------------------------------------
# Check for system-wide dependencies

HAVE_PROJECTM = $(shell pkg-config --exists libprojectM && echo true)

# --------------------------------------------------------------

ifneq ($(CROSS_COMPILING),true)
@@ -65,7 +60,7 @@ ifeq ($(HAVE_OPENGL),true)
$(MAKE) all -C plugins/ProM
endif # HAVE_OPENGL

ifneq ($(HAVE_PROJECTM),true)
ifneq ($(HAVE_OPENGL),true)
resources: gen
# LV2 fonts
install -d bin/ProM.lv2/resources/fonts
@@ -82,9 +77,6 @@ ifeq ($(MACOS),true)
install -d bin/ProM.vst/Contents/Resources/presets
ln -sf $(CURDIR)/plugins/ProM/projectM/presets/presets_* bin/ProM.vst/Contents/Resources/presets/
else
# VST2 directory
install -d bin/ProM.vst
mv bin/ProM-vst$(LIB_EXT) bin/ProM.vst/ProM$(LIB_EXT)
# VST2 fonts
install -d bin/ProM.vst/resources/fonts
ln -sf $(CURDIR)/plugins/ProM/projectM/fonts/*.ttf bin/ProM.vst/resources/fonts/
@@ -107,9 +99,6 @@ gen: plugins dpf/utils/lv2_ttl_generator
ifeq ($(CAN_GENERATE_TTL),true)
@$(CURDIR)/dpf/utils/generate-ttl.sh
endif
ifeq ($(MACOS),true)
@$(CURDIR)/dpf/utils/generate-vst-bundles.sh
endif

dpf/utils/lv2_ttl_generator:
$(MAKE) -C dpf/utils/lv2-ttl-generator


+ 32
- 0
dpf/Makefile.base.mk View File

@@ -426,6 +426,38 @@ HAVE_DGL = $(HAVE_X11)
endif
endif

# ---------------------------------------------------------------------------------------------------------------------
# Optional flags

ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
endif

ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
endif

ifeq ($(FILE_BROWSER_DISABLED),true)
BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED
endif

ifeq ($(USE_OPENGL3),true)
BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
endif

ifeq ($(USE_NANOVG_FBO),true)
BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
endif

ifeq ($(USE_NANOVG_FREETYPE),true)
BUILD_CXX_FLAGS += -DFONS_USE_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2)
endif

ifeq ($(USE_RGBA),true)
BUILD_CXX_FLAGS += -DDGL_USE_RGBA
endif


# ---------------------------------------------------------------------------------------------------------------------
# Set app extension



+ 15
- 0
dpf/Makefile.plugins.mk View File

@@ -213,6 +213,18 @@ HAVE_DGL = false
endif
endif

ifeq ($(UI_TYPE),opengl3)
ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += -DDGL_OPENGL -DDGL_USE_OPENGL3 -DHAVE_DGL
DGL_FLAGS += $(OPENGL_FLAGS)
DGL_LIBS += $(OPENGL_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-opengl3.a
HAVE_DGL = true
else
HAVE_DGL = false
endif
endif

ifeq ($(UI_TYPE),vulkan)
ifeq ($(HAVE_VULKAN),true)
DGL_FLAGS += -DDGL_VULKAN -DHAVE_DGL
@@ -313,6 +325,9 @@ $(DPF_PATH)/build/libdgl-cairo.a:
$(DPF_PATH)/build/libdgl-opengl.a:
$(MAKE) -C $(DPF_PATH)/dgl opengl

$(DPF_PATH)/build/libdgl-opengl3.a:
$(MAKE) -C $(DPF_PATH)/dgl opengl3

$(DPF_PATH)/build/libdgl-stub.a:
$(MAKE) -C $(DPF_PATH)/dgl stub



+ 36
- 20
dpf/dgl/Makefile View File

@@ -13,22 +13,6 @@ BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -DDONT_SET_USING_DGL_NAMESPACE -Wno-un
BUILD_CXX_FLAGS += -Isrc/pugl-upstream/include
LINK_FLAGS += $(DGL_LIBS)

ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
endif
ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
endif
ifeq ($(USE_OPENGL3),true)
BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
endif
ifeq ($(USE_NANOVG_FBO),true)
BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
endif
ifeq ($(USE_RGBA),true)
BUILD_CXX_FLAGS += -DDGL_USE_RGBA
endif

# TODO fix these after pugl-upstream is done
BUILD_CXX_FLAGS += -Wno-attributes -Wno-extra -Wno-missing-field-initializers
ifneq ($(MACOS),true)
@@ -85,6 +69,18 @@ endif

# ---------------------------------------------------------------------------------------------------------------------

OBJS_opengl3 = $(OBJS_common) \
../build/dgl/OpenGL.cpp.opengl3.o \
../build/dgl/NanoVG.cpp.opengl3.o

ifeq ($(MACOS),true)
OBJS_opengl3 += ../build/dgl/pugl.mm.opengl3.o
else
OBJS_opengl3 += ../build/dgl/pugl.cpp.opengl3.o
endif

# ---------------------------------------------------------------------------------------------------------------------

OBJS_stub = $(OBJS_common)

ifeq ($(MACOS),true)
@@ -128,10 +124,11 @@ endif

all: $(TARGETS)

cairo: ../build/libdgl-cairo.a
opengl: ../build/libdgl-opengl.a
stub: ../build/libdgl-stub.a
vulkan: ../build/libdgl-vulkan.a
cairo: ../build/libdgl-cairo.a
opengl: ../build/libdgl-opengl.a
opengl3: ../build/libdgl-opengl3.a
stub: ../build/libdgl-stub.a
vulkan: ../build/libdgl-vulkan.a

# ---------------------------------------------------------------------------------------------------------------------

@@ -147,6 +144,12 @@ vulkan: ../build/libdgl-vulkan.a
$(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $^

../build/libdgl-opengl3.a: $(OBJS_opengl3)
-@mkdir -p ../build
@echo "Creating libdgl-opengl3.a"
$(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $^

../build/libdgl-stub.a: $(OBJS_stub)
-@mkdir -p ../build
@echo "Creating libdgl-stub.a"
@@ -207,6 +210,18 @@ vulkan: ../build/libdgl-vulkan.a

# ---------------------------------------------------------------------------------------------------------------------

../build/dgl/%.cpp.opengl3.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -DDGL_USE_OPENGL3 -c -o $@

../build/dgl/%.mm.opengl3.o: src/%.mm
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -DDGL_USE_OPENGL3 -c -ObjC++ -o $@

# ---------------------------------------------------------------------------------------------------------------------

../build/dgl/%.cpp.vulkan.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $< (Vulkan variant)"
@@ -230,6 +245,7 @@ debug:
-include $(OBJS_common:%.o=%.d)
-include $(OBJS_cairo:%.o=%.d)
-include $(OBJS_opengl:%.o=%.d)
-include $(OBJS_opengl3:%.o=%.d)
-include $(OBJS_stub:%.o=%.d)
-include $(OBJS_vulkan:%.o=%.d)



+ 83
- 10
dpf/dgl/src/OpenGL.cpp View File

@@ -33,6 +33,15 @@

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

#ifdef DGL_USE_OPENGL3
static void notImplemented(const char* const name)
{
d_stderr2("OpenGL3 function not implemented: %s", name);
}
#endif

// -----------------------------------------------------------------------
// Color

@@ -43,18 +52,22 @@ void Color::setFor(const GraphicsContext&, const bool includeAlpha)
glColor4f(red, green, blue, alpha);
else
glColor3f(red, green, blue);
#else
notImplemented("Color::setFor");
// unused
(void)includeAlpha;
#endif
}

// -----------------------------------------------------------------------
// Line

#ifndef DGL_USE_OPENGL3
template<typename T>
static void drawLine(const Point<T>& posStart, const Point<T>& posEnd)
{
DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,);

#ifndef DGL_USE_OPENGL3
glBegin(GL_LINES);

{
@@ -63,23 +76,31 @@ static void drawLine(const Point<T>& posStart, const Point<T>& posEnd)
}

glEnd();
#endif
}
#endif

template<typename T>
void Line<T>::draw(const GraphicsContext&, const T width)
{
#ifndef DGL_USE_OPENGL3
DISTRHO_SAFE_ASSERT_RETURN(width != 0,);

glLineWidth(static_cast<GLfloat>(width));
drawLine<T>(posStart, posEnd);
#else
notImplemented("Line::draw");
#endif
}

// deprecated calls
template<typename T>
void Line<T>::draw()
{
#ifndef DGL_USE_OPENGL3
drawLine<T>(posStart, posEnd);
#else
notImplemented("Line::draw");
#endif
}

template class Line<double>;
@@ -92,6 +113,7 @@ template class Line<ushort>;
// -----------------------------------------------------------------------
// Circle

#ifndef DGL_USE_OPENGL3
template<typename T>
static void drawCircle(const Point<T>& pos,
const uint numSegments,
@@ -106,7 +128,6 @@ static void drawCircle(const Point<T>& 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<numSegments; ++i)
@@ -119,13 +140,17 @@ static void drawCircle(const Point<T>& pos,
}

glEnd();
#endif
}
#endif

template<typename T>
void Circle<T>::draw(const GraphicsContext&)
{
#ifndef DGL_USE_OPENGL3
drawCircle<T>(fPos, fNumSegments, fSize, fSin, fCos, false);
#else
notImplemented("Circle::draw");
#endif
}

template<typename T>
@@ -134,20 +159,32 @@ void Circle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
DISTRHO_SAFE_ASSERT_RETURN(lineWidth != 0,);

glLineWidth(static_cast<GLfloat>(lineWidth));
#ifndef DGL_USE_OPENGL3
drawCircle<T>(fPos, fNumSegments, fSize, fSin, fCos, true);
#else
notImplemented("Circle::drawOutline");
#endif
}

// deprecated calls
template<typename T>
void Circle<T>::draw()
{
#ifndef DGL_USE_OPENGL3
drawCircle<T>(fPos, fNumSegments, fSize, fSin, fCos, false);
#else
notImplemented("Circle::draw");
#endif
}

template<typename T>
void Circle<T>::drawOutline()
{
#ifndef DGL_USE_OPENGL3
drawCircle<T>(fPos, fNumSegments, fSize, fSin, fCos, true);
#else
notImplemented("Circle::drawOutline");
#endif
}

template class Circle<double>;
@@ -160,6 +197,7 @@ template class Circle<ushort>;
// -----------------------------------------------------------------------
// Triangle

#ifndef DGL_USE_OPENGL3
template<typename T>
static void drawTriangle(const Point<T>& pos1,
const Point<T>& pos2,
@@ -168,7 +206,6 @@ static void drawTriangle(const Point<T>& pos1,
{
DISTRHO_SAFE_ASSERT_RETURN(pos1 != pos2 && pos1 != pos3,);

#ifndef DGL_USE_OPENGL3
glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES);

{
@@ -178,13 +215,17 @@ static void drawTriangle(const Point<T>& pos1,
}

glEnd();
#endif
}
#endif

template<typename T>
void Triangle<T>::draw(const GraphicsContext&)
{
#ifndef DGL_USE_OPENGL3
drawTriangle<T>(pos1, pos2, pos3, false);
#else
notImplemented("Triangle::draw");
#endif
}

template<typename T>
@@ -193,20 +234,32 @@ void Triangle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
DISTRHO_SAFE_ASSERT_RETURN(lineWidth != 0,);

glLineWidth(static_cast<GLfloat>(lineWidth));
#ifndef DGL_USE_OPENGL3
drawTriangle<T>(pos1, pos2, pos3, true);
#else
notImplemented("Triangle::drawOutline");
#endif
}

// deprecated calls
template<typename T>
void Triangle<T>::draw()
{
#ifndef DGL_USE_OPENGL3
drawTriangle<T>(pos1, pos2, pos3, false);
#else
notImplemented("Triangle::draw");
#endif
}

template<typename T>
void Triangle<T>::drawOutline()
{
#ifndef DGL_USE_OPENGL3
drawTriangle<T>(pos1, pos2, pos3, true);
#else
notImplemented("Triangle::drawOutline");
#endif
}

template class Triangle<double>;
@@ -219,12 +272,12 @@ template class Triangle<ushort>;
// -----------------------------------------------------------------------
// Rectangle

#ifndef DGL_USE_OPENGL3
template<typename T>
static void drawRectangle(const Rectangle<T>& rect, const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(rect.isValid(),);

#ifndef DGL_USE_OPENGL3
glBegin(outline ? GL_LINE_LOOP : GL_QUADS);

{
@@ -247,13 +300,17 @@ static void drawRectangle(const Rectangle<T>& rect, const bool outline)
}

glEnd();
#endif
}
#endif

template<typename T>
void Rectangle<T>::draw(const GraphicsContext&)
{
#ifndef DGL_USE_OPENGL3
drawRectangle<T>(*this, false);
#else
notImplemented("Rectangle::draw");
#endif
}

template<typename T>
@@ -262,20 +319,32 @@ void Rectangle<T>::drawOutline(const GraphicsContext&, const T lineWidth)
DISTRHO_SAFE_ASSERT_RETURN(lineWidth != 0,);

glLineWidth(static_cast<GLfloat>(lineWidth));
#ifndef DGL_USE_OPENGL3
drawRectangle<T>(*this, true);
#else
notImplemented("Rectangle::drawOutline");
#endif
}

// deprecated calls
template<typename T>
void Rectangle<T>::draw()
{
#ifndef DGL_USE_OPENGL3
drawRectangle<T>(*this, false);
#else
notImplemented("Rectangle::draw");
#endif
}

template<typename T>
void Rectangle<T>::drawOutline()
{
#ifndef DGL_USE_OPENGL3
drawRectangle<T>(*this, true);
#else
notImplemented("Rectangle::drawOutline");
#endif
}

template class Rectangle<double>;
@@ -542,29 +611,33 @@ void ImageBaseKnob<OpenGLImage>::onDisplay()
pData->isReady = true;
}

#ifndef DGL_USE_OPENGL3
const int w = static_cast<int>(getWidth());
const int h = static_cast<int>(getHeight());

if (pData->rotationAngle != 0)
{
#ifndef DGL_USE_OPENGL3
glPushMatrix();
#endif

const int w2 = w/2;
const int h2 = h/2;

#ifndef DGL_USE_OPENGL3
glTranslatef(static_cast<float>(w2), static_cast<float>(h2), 0.0f);
glRotatef(normValue*static_cast<float>(pData->rotationAngle), 0.0f, 0.0f, 1.0f);
#endif

Rectangle<int>(-w2, -h2, w, h).draw(context);

#ifndef DGL_USE_OPENGL3
glPopMatrix();
#endif
}
else
{
Rectangle<int>(0, 0, w, h).draw(context);
}
#endif

glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);


+ 147
- 143
dpf/dgl/src/nanovg/fontstash.h View File

@@ -157,31 +157,170 @@ struct FONSttFontImpl {
};
typedef struct FONSttFontImpl FONSttFontImpl;

static FT_Library ftLibrary;
#else

#define STB_TRUETYPE_IMPLEMENTATION
static void* fons__tmpalloc(size_t size, void* up);
static void fons__tmpfree(void* ptr, void* up);
#define STBTT_malloc(x,u) fons__tmpalloc(x,u)
#define STBTT_free(x,u) fons__tmpfree(x,u)
#include "stb_truetype.h"

struct FONSttFontImpl {
stbtt_fontinfo font;
};
typedef struct FONSttFontImpl FONSttFontImpl;

#endif

#ifndef FONS_SCRATCH_BUF_SIZE
# define FONS_SCRATCH_BUF_SIZE 96000
#endif
#ifndef FONS_HASH_LUT_SIZE
# define FONS_HASH_LUT_SIZE 256
#endif
#ifndef FONS_INIT_FONTS
# define FONS_INIT_FONTS 4
#endif
#ifndef FONS_INIT_GLYPHS
# define FONS_INIT_GLYPHS 256
#endif
#ifndef FONS_INIT_ATLAS_NODES
# define FONS_INIT_ATLAS_NODES 256
#endif
#ifndef FONS_VERTEX_COUNT
# define FONS_VERTEX_COUNT 1024
#endif
#ifndef FONS_MAX_STATES
# define FONS_MAX_STATES 20
#endif
#ifndef FONS_MAX_FALLBACKS
# define FONS_MAX_FALLBACKS 20
#endif

static unsigned int fons__hashint(unsigned int a)
{
a += ~(a<<15);
a ^= (a>>10);
a += (a<<3);
a ^= (a>>6);
a += ~(a<<11);
a ^= (a>>16);
return a;
}

static int fons__mini(int a, int b)
{
return a < b ? a : b;
}

static int fons__maxi(int a, int b)
{
return a > b ? a : b;
}

struct FONSglyph
{
unsigned int codepoint;
int index;
int next;
short size, blur;
short x0,y0,x1,y1;
short xadv,xoff,yoff;
};
typedef struct FONSglyph FONSglyph;

struct FONSfont
{
FONSttFontImpl font;
char name[64];
unsigned char* data;
int dataSize;
unsigned char freeData;
float ascender;
float descender;
float lineh;
FONSglyph* glyphs;
int cglyphs;
int nglyphs;
int lut[FONS_HASH_LUT_SIZE];
int fallbacks[FONS_MAX_FALLBACKS];
int nfallbacks;
};
typedef struct FONSfont FONSfont;

struct FONSstate
{
int font;
int align;
float size;
unsigned int color;
float blur;
float spacing;
};
typedef struct FONSstate FONSstate;

struct FONSatlasNode {
short x, y, width;
};
typedef struct FONSatlasNode FONSatlasNode;

struct FONSatlas
{
int width, height;
FONSatlasNode* nodes;
int nnodes;
int cnodes;
};
typedef struct FONSatlas FONSatlas;

struct FONScontext
{
FONSparams params;
float itw,ith;
unsigned char* texData;
int dirtyRect[4];
FONSfont** fonts;
FONSatlas* atlas;
int cfonts;
int nfonts;
float verts[FONS_VERTEX_COUNT*2];
float tcoords[FONS_VERTEX_COUNT*2];
unsigned int colors[FONS_VERTEX_COUNT];
int nverts;
unsigned char* scratch;
int nscratch;
FONSstate states[FONS_MAX_STATES];
int nstates;
void (*handleError)(void* uptr, int error, int val);
void* errorUptr;
#ifdef FONS_USE_FREETYPE
FT_Library ftLibrary;
#endif
};

#ifdef FONS_USE_FREETYPE

int fons__tt_init(FONScontext *context)
{
FT_Error ftError;
FONS_NOTUSED(context);
ftError = FT_Init_FreeType(&ftLibrary);
ftError = FT_Init_FreeType(&context->ftLibrary);
return ftError == 0;
}

int fons__tt_done(FONScontext *context)
{
FT_Error ftError;
FONS_NOTUSED(context);
ftError = FT_Done_FreeType(ftLibrary);
ftError = FT_Done_FreeType(context->ftLibrary);
return ftError == 0;
}

int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize, int fontIndex)
{
FT_Error ftError;
FONS_NOTUSED(context);

//font->font.userdata = stash;
ftError = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)data, dataSize, fontIndex, &font->font);
ftError = FT_New_Memory_Face(context->ftLibrary, (const FT_Byte*)data, dataSize, fontIndex, &font->font);
return ftError == 0;
}

@@ -269,18 +408,6 @@ int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2)

#else

#define STB_TRUETYPE_IMPLEMENTATION
static void* fons__tmpalloc(size_t size, void* up);
static void fons__tmpfree(void* ptr, void* up);
#define STBTT_malloc(x,u) fons__tmpalloc(x,u)
#define STBTT_free(x,u) fons__tmpfree(x,u)
#include "stb_truetype.h"

struct FONSttFontImpl {
stbtt_fontinfo font;
};
typedef struct FONSttFontImpl FONSttFontImpl;

int fons__tt_init(FONScontext *context)
{
FONS_NOTUSED(context);
@@ -350,129 +477,6 @@ int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2)

#endif

#ifndef FONS_SCRATCH_BUF_SIZE
# define FONS_SCRATCH_BUF_SIZE 96000
#endif
#ifndef FONS_HASH_LUT_SIZE
# define FONS_HASH_LUT_SIZE 256
#endif
#ifndef FONS_INIT_FONTS
# define FONS_INIT_FONTS 4
#endif
#ifndef FONS_INIT_GLYPHS
# define FONS_INIT_GLYPHS 256
#endif
#ifndef FONS_INIT_ATLAS_NODES
# define FONS_INIT_ATLAS_NODES 256
#endif
#ifndef FONS_VERTEX_COUNT
# define FONS_VERTEX_COUNT 1024
#endif
#ifndef FONS_MAX_STATES
# define FONS_MAX_STATES 20
#endif
#ifndef FONS_MAX_FALLBACKS
# define FONS_MAX_FALLBACKS 20
#endif

static unsigned int fons__hashint(unsigned int a)
{
a += ~(a<<15);
a ^= (a>>10);
a += (a<<3);
a ^= (a>>6);
a += ~(a<<11);
a ^= (a>>16);
return a;
}

static int fons__mini(int a, int b)
{
return a < b ? a : b;
}

static int fons__maxi(int a, int b)
{
return a > b ? a : b;
}

struct FONSglyph
{
unsigned int codepoint;
int index;
int next;
short size, blur;
short x0,y0,x1,y1;
short xadv,xoff,yoff;
};
typedef struct FONSglyph FONSglyph;

struct FONSfont
{
FONSttFontImpl font;
char name[64];
unsigned char* data;
int dataSize;
unsigned char freeData;
float ascender;
float descender;
float lineh;
FONSglyph* glyphs;
int cglyphs;
int nglyphs;
int lut[FONS_HASH_LUT_SIZE];
int fallbacks[FONS_MAX_FALLBACKS];
int nfallbacks;
};
typedef struct FONSfont FONSfont;

struct FONSstate
{
int font;
int align;
float size;
unsigned int color;
float blur;
float spacing;
};
typedef struct FONSstate FONSstate;

struct FONSatlasNode {
short x, y, width;
};
typedef struct FONSatlasNode FONSatlasNode;

struct FONSatlas
{
int width, height;
FONSatlasNode* nodes;
int nnodes;
int cnodes;
};
typedef struct FONSatlas FONSatlas;

struct FONScontext
{
FONSparams params;
float itw,ith;
unsigned char* texData;
int dirtyRect[4];
FONSfont** fonts;
FONSatlas* atlas;
int cfonts;
int nfonts;
float verts[FONS_VERTEX_COUNT*2];
float tcoords[FONS_VERTEX_COUNT*2];
unsigned int colors[FONS_VERTEX_COUNT];
int nverts;
unsigned char* scratch;
int nscratch;
FONSstate states[FONS_MAX_STATES];
int nstates;
void (*handleError)(void* uptr, int error, int val);
void* errorUptr;
};

#ifdef STB_TRUETYPE_IMPLEMENTATION

static void* fons__tmpalloc(size_t size, void* up)
@@ -1684,8 +1688,8 @@ void fonsDeleteInternal(FONScontext* stash)
if (stash->fonts) free(stash->fonts);
if (stash->texData) free(stash->texData);
if (stash->scratch) free(stash->scratch);
free(stash);
fons__tt_done(stash);
free(stash);
}

void fonsSetErrorCallback(FONScontext* stash, void (*callback)(void* uptr, int error, int val), void* uptr)


+ 2
- 2
dpf/distrho/src/DistrhoPluginVST2.cpp View File

@@ -189,7 +189,7 @@ public:
sendNoteCallback,
setSizeCallback,
nullptr, // TODO file request
nullptr,
d_nextBundlePath,
plugin->getInstancePointer(),
scaleFactor)
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
@@ -705,7 +705,7 @@ public:
else
{
UIExporter tmpUI(nullptr, 0, fPlugin.getSampleRate(),
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, d_nextBundlePath,
fPlugin.getInstancePointer(), fLastScaleFactor);
fVstRect.right = tmpUI.getWidth();
fVstRect.bottom = tmpUI.getHeight();


+ 1
- 0
dpf/distrho/src/DistrhoUIInternal.hpp View File

@@ -62,6 +62,7 @@ public:
uiData(new UI::PrivateData())
{
uiData->sampleRate = sampleRate;
uiData->bundlePath = bundlePath != nullptr ? strdup(bundlePath) : nullptr;
uiData->dspPtr = dspPtr;

uiData->bgColor = bgColor;


+ 7
- 2
dpf/distrho/src/DistrhoUIVST3.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -47,6 +47,11 @@ static constexpr const sendNoteFunc sendNoteCallback = nullptr;
static constexpr const setStateFunc setStateCallback = nullptr;
#endif

// --------------------------------------------------------------------------------------------------------------------
// Static data, see DistrhoPlugin.cpp

extern const char* d_nextBundlePath;

// --------------------------------------------------------------------------------------------------------------------
// Utility functions (defined on plugin side)

@@ -129,7 +134,7 @@ public:
sendNoteCallback,
setSizeCallback,
nullptr, // TODO file request
nullptr, // bundlePath
d_nextBundlePath,
instancePointer,
scaleFactor)
{


+ 1
- 1
plugins/Nekobi/DistrhoPluginInfo.h View File

@@ -22,7 +22,7 @@
#define DISTRHO_PLUGIN_NAME "Nekobi"
#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/Nekobi"

#define DISTRHO_PLUGIN_HAS_UI 0
#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
#define DISTRHO_PLUGIN_IS_SYNTH 1
#define DISTRHO_PLUGIN_NUM_INPUTS 0


+ 1
- 1
plugins/Nekobi/Makefile View File

@@ -15,7 +15,7 @@ NAME = Nekobi
FILES_DSP = \
DistrhoPluginNekobi.cpp

FILES_UIxx = \
FILES_UI = \
DistrhoArtworkNekobi.cpp \
DistrhoUINekobi.cpp



+ 26
- 78
plugins/ProM/DistrhoUIProM.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO ProM Plugin
* Copyright (C) 2015-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2015-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -26,77 +26,16 @@
#include "DistrhoPluginProM.hpp"
#include "DistrhoUIProM.hpp"

#ifndef DISTRHO_OS_WINDOWS
# include <dlfcn.h>
#endif

#ifdef DISTRHO_OS_WINDOWS
static HINSTANCE hInstance = nullptr;

DISTRHO_PLUGIN_EXPORT
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH)
hInstance = hInst;
return 1;
}
#endif
#include "DistrhoPluginUtils.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

static String getCurrentExecutableDataDir()
{
static String datadir;

if (datadir.isNotEmpty())
return datadir;

#ifdef DISTRHO_OS_WINDOWS
CHAR filename[MAX_PATH + 256];
filename[0] = '\0';
GetModuleFileName(hInstance, filename, sizeof(filename));

datadir = String(filename);
datadir.truncate(datadir.rfind('\\'));
#else
Dl_info info;
dladdr((void*)getCurrentExecutableDataDir, &info);

datadir = String(info.dli_fname);
datadir.truncate(datadir.rfind('/'));

# ifdef DISTRHO_OS_MAC
if (datadir.endsWith("/MacOS"))
{
datadir.truncate(datadir.rfind('/'));
datadir += "/Resources";
}
else
# endif
if (datadir.endsWith("/x86_64-linux"))
{
datadir.truncate(datadir.rfind('/'));
datadir += "/Resources";
}
else
#endif
{
datadir += "/resources";
}

return datadir;
}

// -----------------------------------------------------------------------

DistrhoUIProM::DistrhoUIProM()
: UI(512, 512),
fPM(nullptr)
#ifndef DGL_USE_OPENGL3
, fResizeHandle(this)
#endif
fPM(nullptr),
fResizeHandle(this)
{
const double scaleFactor = getScaleFactor();

@@ -106,10 +45,8 @@ DistrhoUIProM::DistrhoUIProM()
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()
@@ -151,7 +88,7 @@ void DistrhoUIProM::uiIdle()
}
}

void DistrhoUIProM::uiReshape(uint width, uint height)
void DistrhoUIProM::uiReshape(const uint width, const uint height)
{
UI::uiReshape(width, height);

@@ -160,19 +97,27 @@ void DistrhoUIProM::uiReshape(uint width, uint height)
#ifdef PROJECTM_DATA_DIR
fPM = new projectM(PROJECTM_DATA_DIR "/config.inp");
#else
const String datadir(getCurrentExecutableDataDir());
d_stdout("ProM datadir: '%s'", datadir.buffer());

projectM::Settings settings;
settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets";
settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf";
settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf";
settings.datadir = datadir;
fPM = new projectM(settings);
if (const char* const bundlePath = getBundlePath())
{
const String datadir(getResourcePath(bundlePath));
d_stdout("ProM datadir: '%s'", datadir.buffer());

projectM::Settings settings;
settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets";
settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf";
settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf";
settings.datadir = datadir;
fPM = new projectM(settings);
}
else
{
d_stderr2("ProM: failed to find bundle path, UI will be empty");
}
#endif
}

fPM->projectM_resetGL(width, height);
if (fPM != nullptr)
fPM->projectM_resetGL(width, height);
}

// -----------------------------------------------------------------------
@@ -184,6 +129,9 @@ void DistrhoUIProM::onDisplay()
return;

fPM->renderFrame();

// some projectM versions do not turn off the last set GL program
glUseProgram(0);
}

static projectMKeycode dgl2pmkey(const DGL_NAMESPACE::Key key) noexcept


+ 2
- 11
plugins/ProM/DistrhoUIProM.hpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO ProM Plugin
* Copyright (C) 2015-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2015-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,15 +17,8 @@
#ifndef DISTRHO_UI_PROM_HPP_INCLUDED
#define DISTRHO_UI_PROM_HPP_INCLUDED

#ifdef DISTRHO_OS_MAC
# define DGL_USE_OPENGL3
#endif

#include "DistrhoUI.hpp"

#ifndef DGL_USE_OPENGL3
# include "ResizeHandle.hpp"
#endif
#include "ResizeHandle.hpp"

class projectM;

@@ -59,9 +52,7 @@ protected:

private:
ScopedPointer<projectM> fPM;
#ifndef DGL_USE_OPENGL3
ResizeHandle fResizeHandle;
#endif

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIProM)
};


+ 3
- 0
plugins/ProM/Makefile View File

@@ -26,6 +26,7 @@ HAVE_PROJECTM = $(shell pkg-config --exists libprojectM && echo true)
# --------------------------------------------------------------
# Import base definitions

FILE_BROWSER_DISABLED = true
include ../../dpf/Makefile.base.mk

# --------------------------------------------------------------
@@ -105,6 +106,8 @@ endif # !HAVE_PROJECTM
# --------------------------------------------------------------
# Do some magic

UI_TYPE = opengl3
USE_VST2_BUNDLE = true
include ../../dpf/Makefile.plugins.mk

# --------------------------------------------------------------


+ 37
- 17
plugins/ProM/ResizeHandle.hpp View File

@@ -1,6 +1,6 @@
/*
* Resize handle for DPF
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -29,7 +29,8 @@ public:
explicit ResizeHandle(Window& window)
: TopLevelWidget(window),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}
@@ -38,12 +39,14 @@ public:
explicit ResizeHandle(TopLevelWidget* const tlw)
: TopLevelWidget(tlw->getWindow()),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}

/** Set the handle size, minimum 16. */
/** Set the handle size, minimum 16.
* Scale factor is automatically applied on top of this size as needed */
void setHandleSize(const uint size)
{
handleSize = std::max(16u, size);
@@ -53,15 +56,14 @@ public:
protected:
void onDisplay() override
{
// TODO implement gl3 stuff in DPF
#ifndef DGL_USE_OPENGL3
const GraphicsContext& context(getGraphicsContext());
const double lineWidth = 1.0 * getScaleFactor();

#ifdef DGL_OPENGL
glUseProgram(0);
# ifndef DGL_USE_OPENGL3
#if defined(DGL_OPENGL) && !defined(DGL_USE_OPENGL3)
glMatrixMode(GL_MODELVIEW);
# endif
#endif
#endif

// draw white lines, 1px wide
Color(1.0f, 1.0f, 1.0f).setFor(context);
@@ -78,6 +80,7 @@ protected:
l1b.draw(context, lineWidth);
l2b.draw(context, lineWidth);
l3b.draw(context, lineWidth);
#endif
}

bool onMouse(const MouseEvent& ev) override
@@ -87,15 +90,16 @@ protected:

if (ev.press && area.contains(ev.pos))
{
resizing = true;
isResizing = true;
resizingSize = Size<double>(getWidth(), getHeight());
lastResizePoint = ev.pos;
return true;
}

if (resizing && ! ev.press)
if (isResizing && ! ev.press)
{
resizing = false;
isResizing = false;
recheckCursor(ev.pos);
return true;
}

@@ -104,8 +108,11 @@ protected:

bool onMotion(const MotionEvent& ev) override
{
if (! resizing)
if (! isResizing)
{
recheckCursor(ev.pos);
return false;
}

const Size<double> offset(ev.pos.getX() - lastResizePoint.getX(),
ev.pos.getY() - lastResizePoint.getY());
@@ -113,9 +120,11 @@ protected:
resizingSize += offset;
lastResizePoint = ev.pos;

// TODO min width, min height
const uint minWidth = 16;
const uint minHeight = 16;
// TODO keepAspectRatio
bool keepAspectRatio;
const Size<uint> minSize(getWindow().getGeometryConstraints(keepAspectRatio));
const uint minWidth = minSize.getWidth();
const uint minHeight = minSize.getHeight();

if (resizingSize.getWidth() < minWidth)
resizingSize.setWidth(minWidth);
@@ -142,10 +151,21 @@ private:
uint handleSize;

// event handling state
bool resizing;
bool hasCursor, isResizing;
Point<double> lastResizePoint;
Size<double> resizingSize;

void recheckCursor(const Point<double>& pos)
{
const bool shouldHaveCursor = area.contains(pos);

if (shouldHaveCursor == hasCursor)
return;

hasCursor = shouldHaveCursor;
setCursor(shouldHaveCursor ? kMouseCursorDiagonal : kMouseCursorArrow);
}

void resetArea()
{
const double scaleFactor = getScaleFactor();


+ 7
- 2
plugins/glBars/DistrhoUIGLBars.cpp View File

@@ -3,7 +3,7 @@
* Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
* Copyright (C) 2000 Christian Zander <phoenix@minion.de>
* Copyright (C) 2015 Nedko Arnaudov
* Copyright (C) 2016-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,7 +30,12 @@ DistrhoUIGLBars::DistrhoUIGLBars()
fInitialized(false),
fResizeHandle(this)
{
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
if (isResizable())


+ 37
- 14
plugins/glBars/ResizeHandle.hpp View File

@@ -1,6 +1,6 @@
/*
* Resize handle for DPF
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -29,7 +29,8 @@ public:
explicit ResizeHandle(Window& window)
: TopLevelWidget(window),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}
@@ -38,12 +39,14 @@ public:
explicit ResizeHandle(TopLevelWidget* const tlw)
: TopLevelWidget(tlw->getWindow()),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}

/** Set the handle size, minimum 16. */
/** Set the handle size, minimum 16.
* Scale factor is automatically applied on top of this size as needed */
void setHandleSize(const uint size)
{
handleSize = std::max(16u, size);
@@ -53,12 +56,14 @@ public:
protected:
void onDisplay() override
{
// TODO implement gl3 stuff in DPF
#ifndef DGL_USE_OPENGL3
const GraphicsContext& context(getGraphicsContext());
const double lineWidth = 1.0 * getScaleFactor();

#ifdef DGL_OPENGL
#if defined(DGL_OPENGL) && !defined(DGL_USE_OPENGL3)
glMatrixMode(GL_MODELVIEW);
#endif
#endif

// draw white lines, 1px wide
Color(1.0f, 1.0f, 1.0f).setFor(context);
@@ -75,6 +80,7 @@ protected:
l1b.draw(context, lineWidth);
l2b.draw(context, lineWidth);
l3b.draw(context, lineWidth);
#endif
}

bool onMouse(const MouseEvent& ev) override
@@ -84,15 +90,16 @@ protected:

if (ev.press && area.contains(ev.pos))
{
resizing = true;
isResizing = true;
resizingSize = Size<double>(getWidth(), getHeight());
lastResizePoint = ev.pos;
return true;
}

if (resizing && ! ev.press)
if (isResizing && ! ev.press)
{
resizing = false;
isResizing = false;
recheckCursor(ev.pos);
return true;
}

@@ -101,8 +108,11 @@ protected:

bool onMotion(const MotionEvent& ev) override
{
if (! resizing)
if (! isResizing)
{
recheckCursor(ev.pos);
return false;
}

const Size<double> offset(ev.pos.getX() - lastResizePoint.getX(),
ev.pos.getY() - lastResizePoint.getY());
@@ -110,9 +120,11 @@ protected:
resizingSize += offset;
lastResizePoint = ev.pos;

// TODO min width, min height
const uint minWidth = 16;
const uint minHeight = 16;
// TODO keepAspectRatio
bool keepAspectRatio;
const Size<uint> minSize(getWindow().getGeometryConstraints(keepAspectRatio));
const uint minWidth = minSize.getWidth();
const uint minHeight = minSize.getHeight();

if (resizingSize.getWidth() < minWidth)
resizingSize.setWidth(minWidth);
@@ -139,10 +151,21 @@ private:
uint handleSize;

// event handling state
bool resizing;
bool hasCursor, isResizing;
Point<double> lastResizePoint;
Size<double> resizingSize;

void recheckCursor(const Point<double>& pos)
{
const bool shouldHaveCursor = area.contains(pos);

if (shouldHaveCursor == hasCursor)
return;

hasCursor = shouldHaveCursor;
setCursor(shouldHaveCursor ? kMouseCursorDiagonal : kMouseCursorArrow);
}

void resetArea()
{
const double scaleFactor = getScaleFactor();


Loading…
Cancel
Save