Browse Source

Added new method OpenGLContext::getContextAttachedTo()

tags/2021-05-28
jules 9 years ago
parent
commit
16fa0e8ad9
2 changed files with 11 additions and 0 deletions
  1. +8
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  2. +3
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.h

+ 8
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -700,6 +700,14 @@ Component* OpenGLContext::getTargetComponent() const noexcept
return attachment != nullptr ? attachment->getComponent() : nullptr;
}
OpenGLContext* OpenGLContext::getContextAttachedTo (Component& c) noexcept
{
if (CachedImage* const ci = CachedImage::get (c))
return &(ci->context);
return nullptr;
}
static ThreadLocalValue<OpenGLContext*> currentThreadActiveContext;
OpenGLContext* OpenGLContext::getCurrentContext()


+ 3
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.h View File

@@ -87,6 +87,9 @@ public:
/** Returns the component to which this context is currently attached, or nullptr. */
Component* getTargetComponent() const noexcept;
/** If the given component has an OpenGLContext attached, then this will return it. */
static OpenGLContext* getContextAttachedTo (Component& component) noexcept;
//==============================================================================
/** Sets the pixel format which you'd like to use for the target GL surface.
Note: This must be called BEFORE attaching your context to a target component!


Loading…
Cancel
Save