Skip to content

Commit 28dd8b0

Browse files
committed
Use dpf utils for finding resources; Ensure GL3 usage
1 parent 8a6214b commit 28dd8b0

File tree

6 files changed

+45
-84
lines changed

6 files changed

+45
-84
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ ifeq ($(MACOS),true)
3838
install -d bin/ProM.vst/Contents/Resources/presets
3939
ln -sf $(CURDIR)/plugins/ProM/projectM/presets/presets_* bin/ProM.vst/Contents/Resources/presets/
4040
else
41-
# VST2 directory
42-
install -d bin/ProM.vst
43-
mv bin/ProM-vst$(LIB_EXT) bin/ProM.vst/ProM$(LIB_EXT)
4441
# VST2 fonts
4542
install -d bin/ProM.vst/resources/fonts
4643
ln -sf $(CURDIR)/plugins/ProM/projectM/fonts/*.ttf bin/ProM.vst/resources/fonts/
@@ -62,9 +59,6 @@ endif
6259
ifneq ($(CROSS_COMPILING),true)
6360
gen: plugins dpf/utils/lv2_ttl_generator
6461
@$(CURDIR)/dpf/utils/generate-ttl.sh
65-
ifeq ($(MACOS),true)
66-
@$(CURDIR)/dpf/utils/generate-vst-bundles.sh
67-
endif
6862

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

plugins/ProM/DistrhoUIProM.cpp

Lines changed: 31 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -26,84 +26,31 @@
2626
#include "DistrhoPluginProM.hpp"
2727
#include "DistrhoUIProM.hpp"
2828

29-
#ifndef DISTRHO_OS_WINDOWS
30-
# include <dlfcn.h>
31-
#endif
32-
33-
#ifdef DISTRHO_OS_WINDOWS
34-
static HINSTANCE hInstance = nullptr;
35-
36-
DISTRHO_PLUGIN_EXPORT
37-
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
38-
{
39-
if (reason == DLL_PROCESS_ATTACH)
40-
hInstance = hInst;
41-
return 1;
42-
}
43-
#endif
29+
#include "DistrhoPluginUtils.hpp"
4430

4531
START_NAMESPACE_DISTRHO
4632

4733
// -----------------------------------------------------------------------
4834

49-
static String getCurrentExecutableDataDir()
50-
{
51-
static String datadir;
52-
53-
if (datadir.isNotEmpty())
54-
return datadir;
55-
56-
#ifdef DISTRHO_OS_WINDOWS
57-
CHAR filename[MAX_PATH + 256];
58-
filename[0] = '\0';
59-
GetModuleFileName(hInstance, filename, sizeof(filename));
60-
61-
datadir = String(filename);
62-
datadir.truncate(datadir.rfind('\\'));
63-
#else
64-
Dl_info info;
65-
dladdr((void*)getCurrentExecutableDataDir, &info);
66-
67-
datadir = String(info.dli_fname);
68-
datadir.truncate(datadir.rfind('/'));
69-
70-
# ifdef DISTRHO_OS_MAC
71-
if (datadir.endsWith("/MacOS"))
72-
{
73-
datadir.truncate(datadir.rfind('/'));
74-
datadir += "/Resources";
75-
}
76-
else
77-
# endif
78-
if (datadir.endsWith("/x86_64-linux"))
79-
{
80-
datadir.truncate(datadir.rfind('/'));
81-
datadir += "/Resources";
82-
}
83-
else
84-
#endif
85-
{
86-
datadir += "/resources";
87-
}
88-
89-
return datadir;
90-
}
91-
92-
// -----------------------------------------------------------------------
93-
9435
DistrhoUIProM::DistrhoUIProM()
9536
: UI(512, 512),
96-
fPM(nullptr),
97-
fResizeHandle(this)
37+
fPM(nullptr)
38+
#ifndef DGL_USE_OPENGL3
39+
, fResizeHandle(this)
40+
#endif
9841
{
99-
// const double scaleFactor = getScaleFactor();
100-
// if (d_isNotZero(scaleFactor))
101-
// setSize(512*scaleFactor, 512*scaleFactor)
102-
setGeometryConstraints(256, 256, true);
42+
const double scaleFactor = getScaleFactor();
43+
44+
if (d_isNotZero(scaleFactor))
45+
setSize(512*scaleFactor, 512*scaleFactor);
46+
47+
setGeometryConstraints(256*scaleFactor, 256*scaleFactor, true);
10348

10449
// no need to show resize handle if window is user-resizable
50+
#ifndef DGL_USE_OPENGL3
10551
// if (isResizable())
10652
// fResizeHandle.hide();
53+
#endif
10754
}
10855

10956
DistrhoUIProM::~DistrhoUIProM()
@@ -154,19 +101,27 @@ void DistrhoUIProM::uiReshape(uint width, uint height)
154101
#ifdef PROJECTM_DATA_DIR
155102
fPM = new projectM(PROJECTM_DATA_DIR "/config.inp");
156103
#else
157-
const String datadir(getCurrentExecutableDataDir());
158-
d_stdout("ProM datadir: '%s'", datadir.buffer());
159-
160-
projectM::Settings settings;
161-
settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets";
162-
settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf";
163-
settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf";
164-
settings.datadir = datadir;
165-
fPM = new projectM(settings);
104+
if (const char* const bundlePath = getBundlePath())
105+
{
106+
const String datadir(getResourcePath(bundlePath));
107+
d_stdout("ProM datadir: '%s'", datadir.buffer());
108+
109+
projectM::Settings settings;
110+
settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets";
111+
settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf";
112+
settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf";
113+
settings.datadir = datadir;
114+
fPM = new projectM(settings);
115+
}
116+
else
117+
{
118+
d_stderr2("ProM: failed to find bundle path, UI will be empty");
119+
}
166120
#endif
167121
}
168122

169-
fPM->projectM_resetGL(width, height);
123+
if (fPM != nullptr)
124+
fPM->projectM_resetGL(width, height);
170125
}
171126

172127
// -----------------------------------------------------------------------

plugins/ProM/DistrhoUIProM.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717
#ifndef DISTRHO_UI_PROM_HPP_INCLUDED
1818
#define DISTRHO_UI_PROM_HPP_INCLUDED
1919

20+
#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
21+
# define DGL_USE_OPENGL3
22+
#endif
23+
2024
#include "DistrhoUI.hpp"
21-
#include "ResizeHandle.hpp"
25+
26+
#ifndef DGL_USE_OPENGL3
27+
# include "ResizeHandle.hpp"
28+
#endif
2229

2330
class projectM;
2431

@@ -52,7 +59,9 @@ class DistrhoUIProM : public UI
5259

5360
private:
5461
ScopedPointer<projectM> fPM;
62+
#ifndef DGL_USE_OPENGL3
5563
ResizeHandle fResizeHandle;
64+
#endif
5665

5766
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIProM)
5867
};

plugins/ProM/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ endif # !HAVE_PROJECTM
105105
# --------------------------------------------------------------
106106
# Do some magic
107107

108+
USE_VST2_BUNDLE = true
108109
include ../../dpf/Makefile.plugins.mk
109110

110111
# --------------------------------------------------------------

plugins/ProM/ResizeHandle.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class ResizeHandle : public TopLevelWidget
5858

5959
#ifdef DGL_OPENGL
6060
glUseProgram(0);
61+
# ifndef DGL_USE_OPENGL3
6162
glMatrixMode(GL_MODELVIEW);
63+
# endif
6264
#endif
6365

6466
// draw white lines, 1px wide

0 commit comments

Comments
 (0)