@@ -143,7 +143,7 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
OpenGLComponent::OpenGLComponent() | OpenGLComponent::OpenGLComponent() | ||||
: context (0), | : context (0), | ||||
componentToShareListsWith (0), | |||||
contextToShareListsWith (0), | |||||
needToUpdateViewport (true) | needToUpdateViewport (true) | ||||
{ | { | ||||
setOpaque (true); | setOpaque (true); | ||||
@@ -205,13 +205,13 @@ void OpenGLComponent::setPixelFormat (const OpenGLPixelFormat& formatToUse) | |||||
} | } | ||||
} | } | ||||
void OpenGLComponent::shareWith (OpenGLComponent* const comp) | |||||
void OpenGLComponent::shareWith (OpenGLContext* context) | |||||
{ | { | ||||
if (componentToShareListsWith != comp) | |||||
if (contextToShareListsWith != context) | |||||
{ | { | ||||
const ScopedLock sl (contextLock); | const ScopedLock sl (contextLock); | ||||
deleteContext(); | deleteContext(); | ||||
componentToShareListsWith = comp; | |||||
contextToShareListsWith = context; | |||||
} | } | ||||
} | } | ||||
@@ -225,9 +225,7 @@ bool OpenGLComponent::makeCurrentContextActive() | |||||
{ | { | ||||
context = OpenGLContext::createContextForWindow (this, | context = OpenGLContext::createContextForWindow (this, | ||||
preferredPixelFormat, | preferredPixelFormat, | ||||
componentToShareListsWith != 0 | |||||
? componentToShareListsWith->context | |||||
: 0); | |||||
contextToShareListsWith); | |||||
if (context != 0) | if (context != 0) | ||||
{ | { | ||||
@@ -207,12 +207,18 @@ public: | |||||
/** Returns the pixel format that this component is currently using. */ | /** Returns the pixel format that this component is currently using. */ | ||||
const OpenGLPixelFormat getPixelFormat() const; | const OpenGLPixelFormat getPixelFormat() const; | ||||
/** Specifies another component whose OpenGL context should be shared with | |||||
this one. | |||||
/** Specifies an OpenGL context which should be shared with the one that this | |||||
component is using. | |||||
This is an OpenGL feature that lets two contexts share their texture data. | This is an OpenGL feature that lets two contexts share their texture data. | ||||
Note that this pointer is stored by the component, and when the component | |||||
needs to recreate its internal context for some reason, the same context | |||||
will be used again to share lists. So if you pass a context in here, | |||||
don't delete the context while this component is still using it! You can | |||||
call shareWith (0) to stop this component from sharing with it. | |||||
*/ | */ | ||||
void shareWith (OpenGLComponent* const componentToShareListsWith); | |||||
void shareWith (OpenGLContext* contextToShareListsWith); | |||||
//============================================================================== | //============================================================================== | ||||
/** Flips the openGL buffers over. */ | /** Flips the openGL buffers over. */ | ||||
@@ -323,7 +329,7 @@ private: | |||||
OpenGLComponentWatcher* componentWatcher; | OpenGLComponentWatcher* componentWatcher; | ||||
OpenGLContext* context; | OpenGLContext* context; | ||||
OpenGLComponent* componentToShareListsWith; | |||||
OpenGLContext* contextToShareListsWith; | |||||
CriticalSection contextLock; | CriticalSection contextLock; | ||||
OpenGLPixelFormat preferredPixelFormat; | OpenGLPixelFormat preferredPixelFormat; | ||||
@@ -75,7 +75,8 @@ public: | |||||
/** Renders the Drawable at a given offset within the Graphics context. | /** Renders the Drawable at a given offset within the Graphics context. | ||||
This is basically a quick way of saying: | |||||
The co-ordinates passed-in are used to translate the object relative to its own | |||||
origin before drawing it - this is basically a quick way of saying: | |||||
@code | @code | ||||
draw (g, AffineTransform::translation (x, y)). | draw (g, AffineTransform::translation (x, y)). | ||||
@@ -109,10 +110,14 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns the smallest rectangle that can contain this Drawable object. | /** Returns the smallest rectangle that can contain this Drawable object. | ||||
Co-ordinates are relative to the object's own origin. | |||||
*/ | */ | ||||
virtual void getBounds (float& x, float& y, float& width, float& height) const = 0; | virtual void getBounds (float& x, float& y, float& width, float& height) const = 0; | ||||
/** Returns true if the given point is somewhere inside this Drawable. | /** Returns true if the given point is somewhere inside this Drawable. | ||||
Co-ordinates are relative to the object's own origin. | |||||
*/ | */ | ||||
virtual bool hitTest (float x, float y) const = 0; | virtual bool hitTest (float x, float y) const = 0; | ||||