From 9c8a2b960972b56e2df6323dc221667a966e796f Mon Sep 17 00:00:00 2001 From: Oliver James Date: Mon, 10 Feb 2025 10:31:51 +0000 Subject: [PATCH] OpenGL (Windows): Only trigger async update after first buffer swap This fixes an issue where OpenGL would continuously repaint on Windows. --- modules/juce_opengl/native/juce_OpenGL_windows.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_opengl/native/juce_OpenGL_windows.h b/modules/juce_opengl/native/juce_OpenGL_windows.h index 47faf717d2..194544d3df 100644 --- a/modules/juce_opengl/native/juce_OpenGL_windows.h +++ b/modules/juce_opengl/native/juce_OpenGL_windows.h @@ -142,7 +142,9 @@ public: void swapBuffers() noexcept { SwapBuffers (dc.get()); - triggerAsyncUpdate(); + + if (! std::exchange (haveBuffersBeenSwapped, true)) + triggerAsyncUpdate(); } bool setSwapInterval (int numFramesPerSwap) @@ -425,6 +427,7 @@ private: OpenGLContext* context = nullptr; void* sharedContext = nullptr; double nativeScaleFactor = 1.0; + bool haveBuffersBeenSwapped = false; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext)