Skip to content

Commit

Permalink
Use dpf utils for finding resources; Ensure GL3 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Jan 4, 2022
1 parent 8a6214b commit 28dd8b0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 84 deletions.
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,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/
Expand All @@ -62,9 +59,6 @@ endif
ifneq ($(CROSS_COMPILING),true)
gen: plugins dpf/utils/lv2_ttl_generator
@$(CURDIR)/dpf/utils/generate-ttl.sh
ifeq ($(MACOS),true)
@$(CURDIR)/dpf/utils/generate-vst-bundles.sh
endif

dpf/utils/lv2_ttl_generator:
$(MAKE) -C dpf/utils/lv2-ttl-generator
Expand Down
2 changes: 1 addition & 1 deletion dpf
107 changes: 31 additions & 76 deletions plugins/ProM/DistrhoUIProM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,31 @@
#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),
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()
Expand Down Expand Up @@ -154,19 +101,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);
}

// -----------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion plugins/ProM/DistrhoUIProM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
#ifndef DISTRHO_UI_PROM_HPP_INCLUDED
#define DISTRHO_UI_PROM_HPP_INCLUDED

#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
# define DGL_USE_OPENGL3
#endif

#include "DistrhoUI.hpp"
#include "ResizeHandle.hpp"

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

class projectM;

Expand Down Expand Up @@ -52,7 +59,9 @@ class DistrhoUIProM : public UI

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

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIProM)
};
Expand Down
1 change: 1 addition & 0 deletions plugins/ProM/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ endif # !HAVE_PROJECTM
# --------------------------------------------------------------
# Do some magic

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

# --------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions plugins/ProM/ResizeHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class ResizeHandle : public TopLevelWidget

#ifdef DGL_OPENGL
glUseProgram(0);
# ifndef DGL_USE_OPENGL3
glMatrixMode(GL_MODELVIEW);
# endif
#endif

// draw white lines, 1px wide
Expand Down

0 comments on commit 28dd8b0

Please sign in to comment.