diff --git a/modules/juce_opengl/native/juce_OpenGL_android.h b/modules/juce_opengl/native/juce_OpenGL_android.h index 50fca17622..a2c66b0661 100644 --- a/modules/juce_opengl/native/juce_OpenGL_android.h +++ b/modules/juce_opengl/native/juce_OpenGL_android.h @@ -38,7 +38,7 @@ class OpenGLContext::NativeContext public: NativeContext (Component& component_, const OpenGLPixelFormat& pixelFormat, - const NativeContext* contextToShareWith) + void* /*contextToShareWith*/) : component (component_), isInsideGLCallback (false) { diff --git a/modules/juce_opengl/native/juce_OpenGL_ios.h b/modules/juce_opengl/native/juce_OpenGL_ios.h index 51927d0d43..54e3c9ccc6 100644 --- a/modules/juce_opengl/native/juce_OpenGL_ios.h +++ b/modules/juce_opengl/native/juce_OpenGL_ios.h @@ -46,7 +46,7 @@ class OpenGLContext::NativeContext public: NativeContext (Component& component, const OpenGLPixelFormat& pixelFormat, - const NativeContext* const contextToShareWith) + void* contextToShareWith) : frameBufferHandle (0), colorBufferHandle (0), depthBufferHandle (0), lastWidth (0), lastHeight (0), needToRebuildBuffers (false), swapFrames (0), useDepthBuffer (pixelFormat.depthBufferBits > 0) @@ -73,7 +73,7 @@ public: const NSUInteger type = kEAGLRenderingAPIOpenGLES2; if (contextToShareWith != nullptr) - [context initWithAPI: type sharegroup: [contextToShareWith->context sharegroup]]; + [context initWithAPI: type sharegroup: [(EAGLContext*) contextToShareWith sharegroup]]; else [context initWithAPI: type]; @@ -103,7 +103,7 @@ public: } bool createdOk() const noexcept { return getRawContext() != nullptr; } - void* getRawContext() const noexcept { return glLayer; } + void* getRawContext() const noexcept { return context; } GLuint getFrameBufferID() const noexcept { return frameBufferHandle; } bool makeActive() const noexcept diff --git a/modules/juce_opengl/native/juce_OpenGL_linux.h b/modules/juce_opengl/native/juce_OpenGL_linux.h index 106a3a9cbb..c46a569752 100644 --- a/modules/juce_opengl/native/juce_OpenGL_linux.h +++ b/modules/juce_opengl/native/juce_OpenGL_linux.h @@ -32,7 +32,7 @@ class OpenGLContext::NativeContext public: NativeContext (Component& component, const OpenGLPixelFormat& pixelFormat, - const NativeContext* contextToShareWith_) + void* contextToShareWith_) : renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0), contextToShareWith (contextToShareWith_) { @@ -106,9 +106,7 @@ public: void initialiseOnRenderThread() { ScopedXLock xlock; - renderContext = glXCreateContext (display, bestVisual, - contextToShareWith != nullptr ? contextToShareWith->renderContext : 0, - GL_TRUE); + renderContext = glXCreateContext (display, bestVisual, contextToShareWith, GL_TRUE); makeActive(); } @@ -183,7 +181,7 @@ private: int swapFrames; Rectangle bounds; XVisualInfo* bestVisual; - const NativeContext* contextToShareWith; + void* contextToShareWith; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext); }; diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index 3f43cbc20c..339df6c4b7 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -116,7 +116,7 @@ class OpenGLContext::NativeContext public: NativeContext (Component& component, const OpenGLPixelFormat& pixelFormat, - const NativeContext* contextToShareWith) + void* contextToShareWith) { NSOpenGLPixelFormatAttribute attribs[] = { @@ -140,11 +140,8 @@ public: view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) pixelFormat: format]; - NSOpenGLContext* const sharedContext - = contextToShareWith != nullptr ? contextToShareWith->renderContext : nil; - renderContext = [[[NSOpenGLContext alloc] initWithFormat: format - shareContext: sharedContext] autorelease]; + shareContext: (NSOpenGLContext*) contextToShareWith] autorelease]; setSwapInterval (1); diff --git a/modules/juce_opengl/native/juce_OpenGL_win32.h b/modules/juce_opengl/native/juce_OpenGL_win32.h index 565f06ad35..57473c2144 100644 --- a/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -31,7 +31,7 @@ class OpenGLContext::NativeContext public: NativeContext (Component& component, const OpenGLPixelFormat& pixelFormat, - const NativeContext* contextToShareWith) + void* contextToShareWith) { createNativeWindow (component); @@ -68,7 +68,7 @@ public: } if (contextToShareWith != nullptr) - wglShareLists (contextToShareWith->renderContext, renderContext); + wglShareLists (contextToShareWith, renderContext); component.getTopLevelComponent()->repaint(); component.repaint(); diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 52512c4455..f7d9f7921c 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -30,7 +30,7 @@ public: CachedImage (OpenGLContext& context_, Component& component_, const OpenGLPixelFormat& pixelFormat, - const OpenGLContext* contextToShareWith) + void* contextToShareWith) : Thread ("OpenGL Rendering"), context (context_), component (component_), #if JUCE_OPENGL_ES @@ -40,9 +40,7 @@ public: #endif needsUpdate (true) { - nativeContext = new NativeContext (component, pixelFormat, - contextToShareWith != nullptr ? contextToShareWith->nativeContext - : nullptr); + nativeContext = new NativeContext (component, pixelFormat, contextToShareWith); if (nativeContext->createdOk()) { @@ -487,13 +485,13 @@ void OpenGLContext::setPixelFormat (const OpenGLPixelFormat& preferredPixelForma pixelFormat = preferredPixelFormat; } -void OpenGLContext::setContextToShareWith (const OpenGLContext* context) noexcept +void OpenGLContext::setNativeSharedContext (void* nativeContextToShareWith) noexcept { // This method must not be called when the context has already been attached! // Call it before attaching your context, or use detach() first, before calling this! jassert (nativeContext == nullptr); - contextToShareWith = context; + contextToShareWith = nativeContextToShareWith; } void OpenGLContext::attachTo (Component& component) diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.h b/modules/juce_opengl/opengl/juce_OpenGLContext.h index cda9c4dc88..db021062a2 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.h @@ -86,11 +86,12 @@ public: void setPixelFormat (const OpenGLPixelFormat& preferredPixelFormat) noexcept; /** Provides a context with which you'd like this context's resources to be shared. - The object passed-in here must not be deleted while the context may still be - using it! To turn off sharing, you can call this method with a null pointer. + The object passed-in here is a platform-dependent native context object, and + must not be deleted while this context may still be using it! To turn off sharing, + you can call this method with a null pointer. Note: This must be called BEFORE attaching your context to a target component! */ - void setContextToShareWith (const OpenGLContext* contextToShareWith) noexcept; + void setNativeSharedContext (void* nativeContextToShareWith) noexcept; //============================================================================== /** Attaches the context to a target component. @@ -243,7 +244,7 @@ private: OpenGLRenderer* renderer; ScopedPointer attachment; OpenGLPixelFormat pixelFormat; - const OpenGLContext* contextToShareWith; + void* contextToShareWith; int width, height; bool renderComponents;