| @@ -38,7 +38,7 @@ class OpenGLContext::NativeContext | |||||
| public: | public: | ||||
| NativeContext (Component& component_, | NativeContext (Component& component_, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const NativeContext* contextToShareWith) | |||||
| void* /*contextToShareWith*/) | |||||
| : component (component_), | : component (component_), | ||||
| isInsideGLCallback (false) | isInsideGLCallback (false) | ||||
| { | { | ||||
| @@ -46,7 +46,7 @@ class OpenGLContext::NativeContext | |||||
| public: | public: | ||||
| NativeContext (Component& component, | NativeContext (Component& component, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const NativeContext* const contextToShareWith) | |||||
| void* contextToShareWith) | |||||
| : frameBufferHandle (0), colorBufferHandle (0), depthBufferHandle (0), | : frameBufferHandle (0), colorBufferHandle (0), depthBufferHandle (0), | ||||
| lastWidth (0), lastHeight (0), needToRebuildBuffers (false), | lastWidth (0), lastHeight (0), needToRebuildBuffers (false), | ||||
| swapFrames (0), useDepthBuffer (pixelFormat.depthBufferBits > 0) | swapFrames (0), useDepthBuffer (pixelFormat.depthBufferBits > 0) | ||||
| @@ -73,7 +73,7 @@ public: | |||||
| const NSUInteger type = kEAGLRenderingAPIOpenGLES2; | const NSUInteger type = kEAGLRenderingAPIOpenGLES2; | ||||
| if (contextToShareWith != nullptr) | if (contextToShareWith != nullptr) | ||||
| [context initWithAPI: type sharegroup: [contextToShareWith->context sharegroup]]; | |||||
| [context initWithAPI: type sharegroup: [(EAGLContext*) contextToShareWith sharegroup]]; | |||||
| else | else | ||||
| [context initWithAPI: type]; | [context initWithAPI: type]; | ||||
| @@ -103,7 +103,7 @@ public: | |||||
| } | } | ||||
| bool createdOk() const noexcept { return getRawContext() != nullptr; } | 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; } | GLuint getFrameBufferID() const noexcept { return frameBufferHandle; } | ||||
| bool makeActive() const noexcept | bool makeActive() const noexcept | ||||
| @@ -32,7 +32,7 @@ class OpenGLContext::NativeContext | |||||
| public: | public: | ||||
| NativeContext (Component& component, | NativeContext (Component& component, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const NativeContext* contextToShareWith_) | |||||
| void* contextToShareWith_) | |||||
| : renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0), | : renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0), | ||||
| contextToShareWith (contextToShareWith_) | contextToShareWith (contextToShareWith_) | ||||
| { | { | ||||
| @@ -106,9 +106,7 @@ public: | |||||
| void initialiseOnRenderThread() | void initialiseOnRenderThread() | ||||
| { | { | ||||
| ScopedXLock xlock; | ScopedXLock xlock; | ||||
| renderContext = glXCreateContext (display, bestVisual, | |||||
| contextToShareWith != nullptr ? contextToShareWith->renderContext : 0, | |||||
| GL_TRUE); | |||||
| renderContext = glXCreateContext (display, bestVisual, contextToShareWith, GL_TRUE); | |||||
| makeActive(); | makeActive(); | ||||
| } | } | ||||
| @@ -183,7 +181,7 @@ private: | |||||
| int swapFrames; | int swapFrames; | ||||
| Rectangle<int> bounds; | Rectangle<int> bounds; | ||||
| XVisualInfo* bestVisual; | XVisualInfo* bestVisual; | ||||
| const NativeContext* contextToShareWith; | |||||
| void* contextToShareWith; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext); | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext); | ||||
| }; | }; | ||||
| @@ -116,7 +116,7 @@ class OpenGLContext::NativeContext | |||||
| public: | public: | ||||
| NativeContext (Component& component, | NativeContext (Component& component, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const NativeContext* contextToShareWith) | |||||
| void* contextToShareWith) | |||||
| { | { | ||||
| NSOpenGLPixelFormatAttribute attribs[] = | NSOpenGLPixelFormatAttribute attribs[] = | ||||
| { | { | ||||
| @@ -140,11 +140,8 @@ public: | |||||
| view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) | view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) | ||||
| pixelFormat: format]; | pixelFormat: format]; | ||||
| NSOpenGLContext* const sharedContext | |||||
| = contextToShareWith != nullptr ? contextToShareWith->renderContext : nil; | |||||
| renderContext = [[[NSOpenGLContext alloc] initWithFormat: format | renderContext = [[[NSOpenGLContext alloc] initWithFormat: format | ||||
| shareContext: sharedContext] autorelease]; | |||||
| shareContext: (NSOpenGLContext*) contextToShareWith] autorelease]; | |||||
| setSwapInterval (1); | setSwapInterval (1); | ||||
| @@ -31,7 +31,7 @@ class OpenGLContext::NativeContext | |||||
| public: | public: | ||||
| NativeContext (Component& component, | NativeContext (Component& component, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const NativeContext* contextToShareWith) | |||||
| void* contextToShareWith) | |||||
| { | { | ||||
| createNativeWindow (component); | createNativeWindow (component); | ||||
| @@ -68,7 +68,7 @@ public: | |||||
| } | } | ||||
| if (contextToShareWith != nullptr) | if (contextToShareWith != nullptr) | ||||
| wglShareLists (contextToShareWith->renderContext, renderContext); | |||||
| wglShareLists (contextToShareWith, renderContext); | |||||
| component.getTopLevelComponent()->repaint(); | component.getTopLevelComponent()->repaint(); | ||||
| component.repaint(); | component.repaint(); | ||||
| @@ -30,7 +30,7 @@ public: | |||||
| CachedImage (OpenGLContext& context_, | CachedImage (OpenGLContext& context_, | ||||
| Component& component_, | Component& component_, | ||||
| const OpenGLPixelFormat& pixelFormat, | const OpenGLPixelFormat& pixelFormat, | ||||
| const OpenGLContext* contextToShareWith) | |||||
| void* contextToShareWith) | |||||
| : Thread ("OpenGL Rendering"), | : Thread ("OpenGL Rendering"), | ||||
| context (context_), component (component_), | context (context_), component (component_), | ||||
| #if JUCE_OPENGL_ES | #if JUCE_OPENGL_ES | ||||
| @@ -40,9 +40,7 @@ public: | |||||
| #endif | #endif | ||||
| needsUpdate (true) | needsUpdate (true) | ||||
| { | { | ||||
| nativeContext = new NativeContext (component, pixelFormat, | |||||
| contextToShareWith != nullptr ? contextToShareWith->nativeContext | |||||
| : nullptr); | |||||
| nativeContext = new NativeContext (component, pixelFormat, contextToShareWith); | |||||
| if (nativeContext->createdOk()) | if (nativeContext->createdOk()) | ||||
| { | { | ||||
| @@ -487,13 +485,13 @@ void OpenGLContext::setPixelFormat (const OpenGLPixelFormat& preferredPixelForma | |||||
| pixelFormat = preferredPixelFormat; | 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! | // 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! | // Call it before attaching your context, or use detach() first, before calling this! | ||||
| jassert (nativeContext == nullptr); | jassert (nativeContext == nullptr); | ||||
| contextToShareWith = context; | |||||
| contextToShareWith = nativeContextToShareWith; | |||||
| } | } | ||||
| void OpenGLContext::attachTo (Component& component) | void OpenGLContext::attachTo (Component& component) | ||||
| @@ -86,11 +86,12 @@ public: | |||||
| void setPixelFormat (const OpenGLPixelFormat& preferredPixelFormat) noexcept; | void setPixelFormat (const OpenGLPixelFormat& preferredPixelFormat) noexcept; | ||||
| /** Provides a context with which you'd like this context's resources to be shared. | /** 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! | 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. | /** Attaches the context to a target component. | ||||
| @@ -243,7 +244,7 @@ private: | |||||
| OpenGLRenderer* renderer; | OpenGLRenderer* renderer; | ||||
| ScopedPointer<Attachment> attachment; | ScopedPointer<Attachment> attachment; | ||||
| OpenGLPixelFormat pixelFormat; | OpenGLPixelFormat pixelFormat; | ||||
| const OpenGLContext* contextToShareWith; | |||||
| void* contextToShareWith; | |||||
| int width, height; | int width, height; | ||||
| bool renderComponents; | bool renderComponents; | ||||