24 #ifndef PXR_IMAGING_GLF_GL_CONTEXT_H
25 #define PXR_IMAGING_GLF_GL_CONTEXT_H
28 #include "pxr/imaging/glf/api.h"
33 PXR_NAMESPACE_OPEN_SCOPE
36 typedef std::shared_ptr<class GlfGLContext> GlfGLContextSharedPtr;
72 static void MakeCurrent(
const GlfGLContextSharedPtr& context);
76 static bool AreSharing(GlfGLContextSharedPtr
const & context1,
77 GlfGLContextSharedPtr
const & context2);
100 bool IsSharing(GlfGLContextSharedPtr
const & otherContext);
103 virtual bool IsValid()
const = 0;
126 virtual bool _IsSharing(
const GlfGLContextSharedPtr& rhs)
const = 0;
129 virtual bool _IsEqual(
const GlfGLContextSharedPtr& rhs)
const = 0;
179 ~GlfGLContextScopeHolder();
182 GlfGLContextScopeHolder& operator=(
const GlfGLContextScopeHolder) =
delete;
186 void _MakeNewContextCurrent();
188 void _RestoreOldContext();
191 GlfGLContextSharedPtr _newContext;
192 GlfGLContextSharedPtr _oldContext;
246 static GlfGLContextSharedPtr _GetSharedContext()
251 return GlfGLContextSharedPtr();
255 #define API_GLF_HAS_ANY_GL_CONTEXT_SCOPE_HOLDER 1
309 static GlfGLContextSharedPtr _GetAnyContext()
312 GlfGLContextSharedPtr
const current =
314 if (!(current && current->IsValid())) {
318 return GlfGLContextSharedPtr();
343 virtual GlfGLContextSharedPtr
GetShared() = 0;
350 virtual GlfGLContextSharedPtr
GetCurrent() = 0;
358 PXR_NAMESPACE_CLOSE_SCOPE
GLF_API GlfGLContextScopeHolder(const GlfGLContextSharedPtr &newContext)
Make the given context current and restore the current context when this object is destroyed...
static GLF_API bool AreSharing(GlfGLContextSharedPtr const &context1, GlfGLContextSharedPtr const &context2)
Returns true if context1 and context2 are sharing.
GLF_API bool IsSharing(GlfGLContextSharedPtr const &otherContext)
Returns true if this context is sharing with otherContext.
virtual GlfGLContextSharedPtr GetShared()=0
If this GLContext system supports a shared context this should return it.
virtual bool IsValid() const =0
Returns true if this context is valid.
static GLF_API bool IsInitialized()
Returns whether this interface has been initialized.
virtual bool _IsEqual(const GlfGLContextSharedPtr &rhs) const =0
Returns true if this context is equal to rhs.
virtual GlfGLContextSharedPtr CreateSharingContext()
Creates a new GlfContext that shares GL resources with this context.
static GLF_API GlfGLContextSharedPtr GetSharedGLContext()
Returns an instance for the shared GL context.
virtual void _MakeCurrent()=0
Makes this context current.
Provides window system independent access to GL contexts.
GLF_API bool IsCurrent() const
Returns true if this context is current.
virtual GlfGLContextSharedPtr GetCurrent()=0
Whatever your GLContext system thinks is the current GL context may not really be the current context...
ARCH_API bool ArchIsMainThread()
Return true if the calling thread is the main thread, false otherwise.
static GLF_API void MakeCurrent(const GlfGLContextSharedPtr &context)
Makes context current if valid, otherwise makes no context current.
Helper class to make the shared GL context current.
static GLF_API GlfGLContextSharedPtr GetCurrentGLContext()
Returns an instance for the current GL context.
Architecture-specific thread function calls.
static GLF_API void DoneCurrent()
Makes no context current.
Helper class to make the shared GL context current if there is no valid current context.
Interface for registering a GlfGLContext system.
Helper class to make a GL context current.
virtual bool _IsSharing(const GlfGLContextSharedPtr &rhs) const =0
Returns true if this context is sharing with rhs.