From b15b65decf3d9cbaf9907728e40cac0ca3d218dd Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 15 May 2025 16:23:52 +0100 Subject: [PATCH] DemoRunner: Avoid attempting to nest OpenGL contexts OpenGL contexts normally can't be nested. Previously, when the main renderer for the DemoRunner was set to OpenGL, we would forcibly reset the engine to the software renderer when displaying any heavyweight demo, including the OpenGL demos. 19061e6d introduced a regression, where the rendering engine was no longer reset on Windows, so displaying an OpenGL demo while the global renderer was also set to OpenGL would cause an assertion to fire in the OpenGL Graphics context, after which rendering would fail. With this change in place, we now fall back to the Direct2D renderer, instead of the software renderer, when displaying a heavyweight demo. --- examples/DemoRunner/Source/UI/MainComponent.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/DemoRunner/Source/UI/MainComponent.cpp b/examples/DemoRunner/Source/UI/MainComponent.cpp index 975c32a754..f121892292 100644 --- a/examples/DemoRunner/Source/UI/MainComponent.cpp +++ b/examples/DemoRunner/Source/UI/MainComponent.cpp @@ -286,11 +286,13 @@ MainComponent::MainComponent() if (isHeavyweight) { - #if JUCE_MAC && USE_COREGRAPHICS_RENDERING - setRenderingEngine (1); - #elif ! JUCE_WINDOWS - setRenderingEngine (0); + #if (JUCE_MAC && USE_COREGRAPHICS_RENDERING) || JUCE_WINDOWS + constexpr auto fallbackEngine = 1; + #else + constexpr auto fallbackEngine = 0; #endif + + setRenderingEngine (fallbackEngine); } isShowingHeavyweightDemo = isHeavyweight;