23#if !defined SOGLCONTEXT_H
26#include <Inventor/devices/SoDeviceContext.h>
27#include <Inventor/devices/SoGLFormat.h>
28#include <Inventor/devices/SoGLGlew.h>
29#include <Inventor/STL/vector>
30#include <Inventor/STL/list>
31#include <Inventor/STL/map>
32#include <Inventor/helpers/SbGlContextHelper.h>
33#include <Inventor/threads/SbThreadLocalStorage.h>
34#include <Inventor/threads/SbThreadSpinlock.h>
35#include <Inventor/errors/SoError.h>
36#include <Inventor/image/SbRasterImage.h>
37#include <Inventor/threads/SbThreadLocalStorage.h>
40#include <Inventor/SbPList.h>
41#include <Inventor/STL/stack>
43#include <Inventor/helpers/SbGPUCapabilities.h>
51#pragma warning( push )
52#pragma warning(disable:4251)
56struct GLEWContextStruct;
59class FunctionRedirector;
285 bool shared =
true );
497 SB_THREAD_TLS_HEADER();
499 static void initClass();
500 static void exitClass();
505 GPU_TYPE_NOT_INITIALIZED = -1,
513 static GPUVendorType getGPUVendorType();
531 void setUserData(
void* data )
532 { m_userData = data; }
535 void* getUserData()
const
536 {
return m_userData; }
551 { m_context = context; }
554 inline void forceNoGLContextDelete(
bool flag) { m_noOGLContextDelete = flag; }
558 {
return m_drawable;}
568 void printInformation();
573 static void printCurrentContextInformation();
578 static void printContextsInformation();
612 bool setVSyncEnabled(
bool SO_UNUSED_PARAM(on));
619 bool isVSyncEnabled();
624 static GLEWContextStruct* glewGetCurrentContext();
625 static SoGLGlew::GlewContextNative* glewGetCurrentContextNative();
638 void removeSharedObjects();
643 void checkRefCount()
const;
652 void setSwapInterval(
int interval);
657 typedef std::vector<SoGLContext*> ContextVec;
659 ContextVec* m_bindedContexts;
662 bool initContext(
SoGLContext* sourceContext,
bool shared );
663 void preInitContext();
664 bool postInitContext();
666 void checkContextParameters(
const char* function );
670 typedef std::list< SoGLContext* > SoGLContextList;
673 static SoGLContextList s_contexts;
676 static int s_firstAvailableId;
697 static GPUVendorType m_GpuVendorType;
699 bool m_noOGLContextDelete;
701 bool m_drawableIsValid;
702 bool m_displayIsValid;
704 static int s_checkContext;
706 static int s_oivCompatibilityMode;
712 bool m_sharedObjectsRemoved;
715 bool m_displayWarning;
718 void pushInBindedList();
719 static void updateBindedList();
723 bool m_thirdPartyContext;
724 bool m_isBeingDestroyed;
726 static FunctionRedirector s_deleteContextRedirector;
733#elif defined(__APPLE__)
739 static MTstruct::ContextVec& getBindedContextsList();
743#pragma warning( pop )
List of common graphics capabilities of the device used by a SoGLContext.
Class for smart character strings.
Maintains a list of pointers to SbString instances.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable spinloc...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> OpenGL context m...
virtual void bind()
Bind the OpenGL context to the current thread.
virtual bool isValid() const
Returns true if this context is valid.
virtual bool tryBind()
Try to bind the OpenGL context to the current thread.
bool isValidForCurrent() const
Returns true if the context is the current active context or if it is shared with the current active ...
SharedGroupPolicy
Sharing Policy.
@ CONSERVATIVE
Conservative sharing (not available on Unix) Only add context to a share group containing contexts ...
@ AGGRESSIVE
Aggressive sharing (default) Tries to share contexts, independent of their sharing constraint.
@ DISABLED
Disables context sharing (same behavior as v2.6 and older)
virtual bool isCurrent() const
Returns true if this context is valid and currently active.
SoGLContext(SoGLContext *context, bool shared)
Constructor which creates an SoGLContext based on the attributes of the specified context.
int getId() const
Returns the internal id for this context.
static SoGLContext * getContextFromId(int id)
Returns the context corresponding to an internal id.
static SoGLContext * findGLContext(SbGlContextHelper::GLContext)
Returns the first SoGLContext associated with the specified OpenGL context.
void invalidate()
Set this context as invalid so it won't be used anymore.
static const SbGPUCapabilities & getGraphicsCapabilities()
Retrieve graphics capabilities from the current bound context, if any.
static SoGLContext * getCurrent(bool checkGLState=false)
Returns the current active OpenGL context (if any).
SbGlContextHelper::Display SharedGroupDescription
Returns an SoGLContext that matches the specified SharedGroupDescription.
SoGLContext(SbGlContextHelper::Display dpy, SbGlContextHelper::VisualInfo vis, SbGlContextHelper::Drawable drawable, SbGlContextHelper::GLContext ctx)
Constructor which creates an SoGLContext based on the specifed parameters.
bool swapBuffers()
Swaps the buffers with the value stored in the SoGLFormat, which is set to the main plane by default.
const SbGlContextHelper::VisualInfo & getVisualInfo() const
Returns the VisualInfo of this SoGLContext.
void setNoGLContextDelete()
Prevent deletion of the native OpenGL context by SoGLContext.
const SbGlContextHelper::GLContext & getGLContext() const
Returns the OpenGL rendering context of this SoGLContext.
SoGLContext(SoGLContext *context, const SoGLFormat &format, SbGlContextHelper::Drawable drawable=0)
Constructor which creates a SoGLContext shared with a specific context, but attached to the display s...
bool isSharedWith(const SoDeviceContext *context) const
Returns true if the specified context and this context are shared.
const SbGlContextHelper::Display & getDisplay() const
Returns the Display of this SoGLContext.
const SbGPUCapabilities & getContextGraphicsCapabilities()
Retrieve graphics capabilities from this context.
SoGLContext(SbGlContextHelper::Display dpy, SbGlContextHelper::VisualInfo vis, SbGlContextHelper::Drawable drawable, bool shared=true)
Constructor which creates a SoGLContext based on the specified parameters.
const SoGLFormat & getFormat() const
Returns the SoGLFormat associated to the SoGLContext.
SoGLContext(bool shared)
Constructor which creates an SoGLContext based on the attributes of the current context.
static SharedGroupPolicy getSharedGroupPolicy()
Returns the current sharedGroupPolicy.
virtual bool isCompatible(SoDeviceContext *context) const
Returns true if the specified context and this one are compatible.
virtual void unbind()
Unbind the OpenGL context from the current thread.
SoGLContext(const SoGLFormat &format, SbGlContextHelper::Drawable drawable=0)
Constructor which creates a SoGLContext based on the specifed format.
void assertContext() const
Assert this context and the current active context are the same.
static SoGLContext * getContextFromSharedId(int sharedIdGroup)
Returns the first context that belongs to the specified sharedIdGroup.
SoGLContext(const SoGLFormat &format, SbGlContextHelper::GLContext ctx, SbGlContextHelper::Drawable drawable=0)
Constructor which creates a SoGLContext based on the specified parameters.
SbStringList getSupportedExtensions()
Returns an SbString containing the supported extensions for this context.
static SoGLContext * findSharedContext(SharedGroupDescription)