diff --git a/modules/juce_opengl/native/juce_OpenGL_windows.h b/modules/juce_opengl/native/juce_OpenGL_windows.h index 4c8ef365c1..47faf717d2 100644 --- a/modules/juce_opengl/native/juce_OpenGL_windows.h +++ b/modules/juce_opengl/native/juce_OpenGL_windows.h @@ -47,6 +47,7 @@ public: void* contextToShareWithIn, bool /*useMultisampling*/, OpenGLVersion version) + : sharedContext (contextToShareWithIn) { placeholderComponent.reset (new PlaceholderComponent (*this)); createNativeWindow (component); @@ -84,9 +85,6 @@ public: } } - if (contextToShareWithIn != nullptr) - wglShareLists ((HGLRC) contextToShareWithIn, renderContext.get()); - component.getTopLevelComponent()->repaint(); component.repaint(); } @@ -107,6 +105,26 @@ public: { threadAwarenessSetter = std::make_unique (nativeWindow->getNativeHandle()); context = &c; + + if (sharedContext != nullptr) + { + if (! wglShareLists ((HGLRC) sharedContext, renderContext.get())) + { + TCHAR messageBuffer[256] = {}; + + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, + GetLastError(), + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + messageBuffer, + (DWORD) numElementsInArray (messageBuffer) - 1, + nullptr); + + DBG (messageBuffer); + jassertfalse; + } + } + return InitResult::success; } @@ -405,6 +423,7 @@ private: std::unique_ptr, RenderContextDeleter> renderContext; std::unique_ptr, DeviceContextDeleter> dc; OpenGLContext* context = nullptr; + void* sharedContext = nullptr; double nativeScaleFactor = 1.0; //==============================================================================