From 7134bd0f1b1dfd54c41856c463e779484526c99a Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 23 Jan 2019 10:43:28 +0000 Subject: [PATCH] VST: Add juce_shouldDoubleScaleNativeGLWindow() method to ensure that OpenGL plug-ins running in hiDPI Cubase 10 on Windows are correctly scaled --- .../utility/juce_PluginUtilities.cpp | 12 ++++++++++++ modules/juce_opengl/native/juce_OpenGL_win32.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp index 9b5c214f06..b9e97ee9d0 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp +++ b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp @@ -43,6 +43,18 @@ AudioProcessor::WrapperType PluginHostType::jucePlugInClientCurrentWrapperType = bool juce_isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; } #endif +#if JUCE_MODULE_AVAILABLE_juce_opengl + bool juce_shouldDoubleScaleNativeGLWindow() + { + auto wrapperType = PluginHostType::getPluginLoadedAs(); + + if (wrapperType == AudioProcessor::wrapperType_VST || wrapperType == AudioProcessor::wrapperType_VST3) + return getHostType().type == PluginHostType::SteinbergCubase10; + + return false; + } +#endif + #ifndef JUCE_VST3_CAN_REPLACE_VST2 #define JUCE_VST3_CAN_REPLACE_VST2 1 #endif diff --git a/modules/juce_opengl/native/juce_OpenGL_win32.h b/modules/juce_opengl/native/juce_OpenGL_win32.h index 03f6f9ef12..a0811b6a95 100644 --- a/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -30,6 +30,12 @@ namespace juce extern ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component&, void* parent); extern bool shouldScaleGLWindow (void* hwnd); +#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client && (JucePlugin_Build_VST || JucePlugin_Build_VST3) + bool juce_shouldDoubleScaleNativeGLWindow(); +#else + bool juce_shouldDoubleScaleNativeGLWindow() { return false; } +#endif + //============================================================================== class OpenGLContext::NativeContext #if JUCE_WIN_PER_MONITOR_DPI_AWARE @@ -191,6 +197,9 @@ private: { auto newScale = peer->getPlatformScaleFactor(); + if (juce_shouldDoubleScaleNativeGLWindow()) + newScale *= newScale; + if (! approximatelyEqual (newScale, nativeScaleFactor)) { nativeScaleFactor = newScale; @@ -220,6 +229,10 @@ private: #if JUCE_WIN_PER_MONITOR_DPI_AWARE safeComponent = Component::SafePointer (&component); nativeScaleFactor = peer->getPlatformScaleFactor(); + + if (juce_shouldDoubleScaleNativeGLWindow()) + nativeScaleFactor *= nativeScaleFactor; + startTimer (50); #endif