mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
OpenGL: Avoid displaying OpenGL window until a frame has been drawn
This avoids an issue where, when attaching an OpenGLContext as a child of a window rendered with Direct2D, the area covered by the OpenGL renderer would display as a white rectangle until the context had drawn a frame. This only affected the Direct2D renderer; when the parent window used the software renderer, no white rectangle was shown.
This commit is contained in:
parent
a784d5776b
commit
fcaf5adb25
1 changed files with 14 additions and 3 deletions
|
|
@ -38,7 +38,8 @@ namespace juce
|
|||
extern ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component&, Component* parent);
|
||||
|
||||
//==============================================================================
|
||||
class OpenGLContext::NativeContext : private ComponentPeer::ScaleFactorListener
|
||||
class OpenGLContext::NativeContext : private ComponentPeer::ScaleFactorListener,
|
||||
private AsyncUpdater
|
||||
{
|
||||
public:
|
||||
NativeContext (Component& component,
|
||||
|
|
@ -93,6 +94,7 @@ public:
|
|||
|
||||
~NativeContext() override
|
||||
{
|
||||
cancelPendingUpdate();
|
||||
renderContext.reset();
|
||||
dc.reset();
|
||||
|
||||
|
|
@ -118,7 +120,12 @@ public:
|
|||
static void deactivateCurrentContext() { wglMakeCurrent (nullptr, nullptr); }
|
||||
bool makeActive() const noexcept { return isActive() || wglMakeCurrent (dc.get(), renderContext.get()) != FALSE; }
|
||||
bool isActive() const noexcept { return wglGetCurrentContext() == renderContext.get(); }
|
||||
void swapBuffers() const noexcept { SwapBuffers (dc.get()); }
|
||||
|
||||
void swapBuffers() noexcept
|
||||
{
|
||||
SwapBuffers (dc.get());
|
||||
triggerAsyncUpdate();
|
||||
}
|
||||
|
||||
bool setSwapInterval (int numFramesPerSwap)
|
||||
{
|
||||
|
|
@ -171,6 +178,11 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
void handleAsyncUpdate() override
|
||||
{
|
||||
nativeWindow->setVisible (true);
|
||||
}
|
||||
|
||||
static void initialiseWGLExtensions (HDC dcIn)
|
||||
{
|
||||
static bool initialised = false;
|
||||
|
|
@ -311,7 +323,6 @@ private:
|
|||
peer->addScaleFactorListener (this);
|
||||
}
|
||||
|
||||
nativeWindow->setVisible (true);
|
||||
dc = std::unique_ptr<std::remove_pointer_t<HDC>, DeviceContextDeleter> { GetDC ((HWND) nativeWindow->getNativeHandle()),
|
||||
DeviceContextDeleter { (HWND) nativeWindow->getNativeHandle() } };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue