14#ifndef OSG_GRAPHICSCONTEXT
15#define OSG_GRAPHICSCONTEXT 1
163 ScreenSettings(
int in_width,
int in_height,
double in_refreshRate=0,
unsigned int in_colorDepth=0) :
204 width = settings.
width;
235 typedef std::vector< osg::ref_ptr<GraphicsContext::WindowingSystemInterface> >
Interfaces;
369 void close(
bool callCloseImplementation=
true);
476 void resized(
int x,
int y,
int width,
int height)
518 virtual const char*
className()
const {
return "GraphicsContext"; }
600#define REGISTER_WINDOWINGSYSTEMINTERFACE(ext, classname) \
601 extern "C" void graphicswindow_##ext(void) {} \
602 static osg::WindowingSystemInterfaceProxy<classname> s_proxy_##classname(#ext);
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
struct __GLsync * GLsync
Definition GLDefines:680
Vec4f Vec4
Definition Vec4:21
unsigned long long Timer_t
Definition Timer:24
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
DisplaySettings class for encapsulating what visuals are required and have been set up,...
Definition DisplaySettings:34
SwapMethod
Definition DisplaySettings:257
Base class for providing Windowing API agnostic access to creating and managing graphics context.
Definition GraphicsContext:30
void removeAllOperations()
Remove all operations from OperationQueue.
virtual bool isSameKindAs(const Object *object) const
Definition GraphicsContext:516
bool isRealized() const
Return true if the graphics context has been realized and is ready to use.
Definition GraphicsContext:375
double getTimeSinceLastClear() const
Definition GraphicsContext:358
const State * getState() const
Get the const State object which tracks the current OpenGL state for this graphics context.
Definition GraphicsContext:337
Vec4 _clearColor
Definition GraphicsContext:547
bool isCurrent() const
Return true if the current thread has this OpenGL graphics context.
Definition GraphicsContext:393
void resized(int x, int y, int width, int height)
resized method should be called when the underlying window has been resized and the GraphicsWindow an...
Definition GraphicsContext:476
ref_ptr< State > _state
Definition GraphicsContext:545
void setSwapCallback(SwapCallback *rc)
Set the swap callback which overrides the GraphicsContext::swapBuffersImplementation(),...
Definition GraphicsContext:449
void setDefaultFboId(GLuint i)
set the default FBO-id, this id will be used when the rendering-backend is finished with RTT FBOs
Definition GraphicsContext:510
static void decrementContextIDUsageCount(unsigned int contextID)
Decrement the usage count associate with a contextID.
osg::ref_ptr< osg::RefBlock > _operationsBlock
Definition GraphicsContext:553
Timer_t _lastClearTick
Definition GraphicsContext:562
GLuint _defaultFboId
Definition GraphicsContext:564
virtual void bindPBufferToTextureImplementation(GLenum buffer)=0
Pure virtual, Bind the graphics context to associated texture implementation.
static GraphicsContexts getRegisteredGraphicsContexts(unsigned int contextID)
Get all the registered graphics contexts associated with a specific contextID.
std::list< ref_ptr< Operation > > GraphicsOperationQueue
Definition GraphicsContext:306
virtual bool makeCurrentImplementation()=0
Make this graphics context current implementation.
osg::ref_ptr< Operation > _currentOperation
Definition GraphicsContext:555
std::list< osg::Camera * > Cameras
Definition GraphicsContext:501
static void registerGraphicsContext(GraphicsContext *gc)
Register a GraphicsContext.
virtual void clear()
Do an OpenGL clear of the full graphics context/window.
std::vector< GraphicsContext * > GraphicsContexts
Definition GraphicsContext:272
SwapCallback * getSwapCallback()
Get the swap callback which overrides the GraphicsContext::swapBuffersImplementation().
Definition GraphicsContext:452
ref_ptr< Traits > _traits
Definition GraphicsContext:544
static unsigned int createNewContextID()
Create a contextID for a new graphics context, this contextID is used to set up the osg::State associ...
void remove(const std::string &name)
Remove named operation from OperationQueue.
Cameras & getCameras()
Get the list of cameras associated with this graphics context.
Definition GraphicsContext:504
static void setCompileContext(unsigned int contextID, GraphicsContext *gc)
Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specifi...
virtual ~GraphicsContext()
GLuint getDefaultFboId() const
Definition GraphicsContext:512
void add(Operation *operation)
Add operation to end of OperationQueue.
std::vector< ScreenSettings > ScreenSettingsList
Definition GraphicsContext:176
ref_ptr< ResizedCallback > _resizedCallback
Definition GraphicsContext:559
virtual void closeImplementation()=0
Close the graphics context implementation.
size_t _threadOfLastMakeCurrent
Definition GraphicsContext:550
GraphicsOperationQueue & getOperationsQueue()
Get the operations queue, note you must use the OperationsMutex when accessing the queue.
Definition GraphicsContext:309
GraphicsThread * getGraphicsThread()
Get the graphics thread assigned the graphics context.
Definition GraphicsContext:407
void bindPBufferToTexture(GLenum buffer)
Bind the graphics context to associated texture.
Definition GraphicsContext:396
osg::RefBlock * getOperationsBlock()
Get the operations queue block used to mark an empty queue, if you end items into the empty queue you...
Definition GraphicsContext:315
const GraphicsThread * getGraphicsThread() const
Get the const graphics thread assigned the graphics context.
Definition GraphicsContext:410
virtual bool makeContextCurrentImplementation(GraphicsContext *readContext)=0
Make this graphics context current with specified read context implementation.
virtual bool isRealizedImplementation() const =0
Return true if the graphics context has been realized, and is ready to use, implementation.
GLbitfield getClearMask() const
Get the clear mask.
Definition GraphicsContext:352
virtual void runOperations()
Run the operations.
Cameras _cameras
Definition GraphicsContext:540
virtual const char * libraryName() const
return the name of the object's library.
Definition GraphicsContext:517
static unsigned int getMaxContextID()
Get the current max ContextID.
void setClearMask(GLbitfield mask)
Set the clear mask used in glClear(..).
Definition GraphicsContext:349
static void incrementContextIDUsageCount(unsigned int contextID)
Increment the usage count associate with a contextID.
virtual bool valid() const =0
Return whether a valid and usable GraphicsContext has been created.
virtual bool realizeImplementation()=0
Realize the GraphicsContext implementation, Pure virtual - must be implemented by concrete implementa...
void setGraphicsThread(GraphicsThread *gt)
Assign a graphics thread to the graphics context, so that the thread handles all OpenGL operations.
ResizedCallback * getResizedCallback()
Get the resized callback which overrides the GraphicsConext::realizedImplementation().
Definition GraphicsContext:492
const Cameras & getCameras() const
Get the const list of cameras associated with this graphics context.
Definition GraphicsContext:507
void setClearColor(const Vec4 &color)
Sets the clear color.
Definition GraphicsContext:341
OpenThreads::Mutex _operationsMutex
Definition GraphicsContext:552
static WindowingSystemInterface * getWindowingSystemInterface(const std::string &name="")
Get the default WindowingSystemInterface for this OS.
ref_ptr< SwapCallback > _swapCallback
Definition GraphicsContext:560
void swapBuffersCallbackOrImplementation()
Convenience method for handling whether to call swapbuffers callback or the standard context swapBuff...
Definition GraphicsContext:460
bool realize()
Realize the GraphicsContext.
virtual bool releaseContextImplementation()=0
Release the graphics context implementation.
GraphicsOperationQueue _operations
Definition GraphicsContext:554
void remove(Operation *operation)
Remove operation from OperationQueue.
void createGraphicsThread()
Create a graphics thread to the graphics context, so that the thread handles all OpenGL operations.
const Traits * getTraits() const
Get the traits of the GraphicsContext.
Definition GraphicsContext:324
const ResizedCallback * getResizedCallback() const
Get the const resized callback which overrides the GraphicsConext::realizedImplementation().
Definition GraphicsContext:495
static void unregisterGraphicsContext(GraphicsContext *gc)
Unregister a GraphicsContext.
void setState(State *state)
Set the State object which tracks the current OpenGL state for this graphics context.
Definition GraphicsContext:331
Operation * getCurrentOperation()
Get the current operations that is being run.
Definition GraphicsContext:318
const SwapCallback * getSwapCallback() const
Get the const swap callback which overrides the GraphicsContext::swapBuffersImplementation().
Definition GraphicsContext:455
State * getState()
Get the State object which tracks the current OpenGL state for this graphics context.
Definition GraphicsContext:334
void removeCamera(osg::Camera *camera)
virtual void resizedImplementation(int x, int y, int width, int height)
resized implementation, by default resizes the viewports and aspect ratios the cameras associated wit...
virtual const char * className() const
return the name of the object's class type.
Definition GraphicsContext:518
GraphicsContext(const GraphicsContext &, const osg::CopyOp &)
static GraphicsContext * createGraphicsContext(Traits *traits)
Create a graphics context for a specified set of traits.
void swapBuffers()
swap the front and back buffers.
bool makeContextCurrent(GraphicsContext *readContext)
Make this graphics context current with specified read context.
ref_ptr< GraphicsThread > _graphicsThread
Definition GraphicsContext:557
const Vec4 & getClearColor() const
Returns the clear color.
Definition GraphicsContext:344
OpenThreads::Mutex * getOperationsMutex()
Get the operations queue mutex.
Definition GraphicsContext:312
static GraphicsContext * getOrCreateCompileContext(unsigned int contextID)
Get existing or create a new GraphicsContext to do background compilation for GraphicsContexts associ...
virtual Object * cloneType() const
Clone the type of an object, with Object* return type.
Definition GraphicsContext:527
GLbitfield _clearMask
Definition GraphicsContext:548
bool releaseContext()
Release the graphics context.
void close(bool callCloseImplementation=true)
close the graphics context.
static GraphicsContext * getCompileContext(unsigned int contextID)
Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specifi...
static osg::ref_ptr< WindowingSystemInterfaces > & getWindowingSystemInterfaces()
virtual Object * clone(const CopyOp &) const
Clone an object, with Object* return type.
Definition GraphicsContext:528
virtual void swapBuffersImplementation()=0
Swap the front and back buffers implementation.
bool makeCurrent()
Make this graphics context current.
void setResizedCallback(ResizedCallback *rc)
Set the resized callback which overrides the GraphicsConext::realizedImplementation(),...
Definition GraphicsContext:489
static GraphicsContexts getAllRegisteredGraphicsContexts()
Get all the registered graphics contexts.
void addCamera(osg::Camera *camera)
Definition GraphicsContext:34
ScreenIdentifier(const std::string &in_hostName, int in_displayNum, int in_screenNum)
void setUndefinedScreenDetailsToDefaultScreen()
Set any undefined displayNum or screenNum values (i.e.
Definition GraphicsContext:57
ScreenIdentifier(int in_screenNum)
std::string hostName
Definition GraphicsContext:63
void readDISPLAY()
Read the DISPLAY environmental variable, and set the ScreenIdentifier accordingly.
std::string displayName() const
Return the display name in the form hostName::displayNum:screenNum.
int screenNum
Definition GraphicsContext:65
void setScreenIdentifier(const std::string &displayName)
Set the screenIndentifier from the displayName string.
int displayNum
Definition GraphicsContext:64
GraphicsContext Traits object provides the specification of what type of graphics context is required...
Definition GraphicsContext:70
int width
Definition GraphicsContext:76
GLenum target
Definition GraphicsContext:108
unsigned int face
Definition GraphicsContext:111
bool vsync
Definition GraphicsContext:115
int y
Definition GraphicsContext:75
unsigned int glContextProfileMask
Definition GraphicsContext:131
bool doubleBuffer
Definition GraphicsContext:105
unsigned int level
Definition GraphicsContext:110
bool getContextVersion(unsigned int &major, unsigned int &minor) const
return true if glContextVersion is set in the form major.minor, and assign the appropriate major and ...
unsigned int red
Definition GraphicsContext:91
bool pbuffer
Definition GraphicsContext:103
osg::ref_ptr< osg::Referenced > inheritedWindowData
Definition GraphicsContext:139
unsigned int samples
Definition GraphicsContext:100
bool useCursor
Definition GraphicsContext:126
std::string windowingSystemPreference
Definition GraphicsContext:83
GLuint swapBarrier
Definition GraphicsContext:120
bool setInheritedWindowPixelFormat
Definition GraphicsContext:142
unsigned int sampleBuffers
Definition GraphicsContext:99
bool swapGroupEnabled
Definition GraphicsContext:118
unsigned int green
Definition GraphicsContext:93
bool useMultiThreadedOpenGLEngine
Definition GraphicsContext:123
bool windowDecoration
Definition GraphicsContext:87
bool overrideRedirect
Definition GraphicsContext:145
bool supportsResize
Definition GraphicsContext:88
osg::observer_ptr< GraphicsContext > sharedContext
Definition GraphicsContext:137
unsigned int glContextFlags
Definition GraphicsContext:130
int height
Definition GraphicsContext:77
DisplaySettings::SwapMethod swapMethod
Definition GraphicsContext:147
OpenThreads::Affinity affinity
Definition GraphicsContext:150
GLuint swapGroup
Definition GraphicsContext:119
unsigned int depth
Definition GraphicsContext:95
bool quadBufferStereo
Definition GraphicsContext:104
int x
Definition GraphicsContext:74
unsigned int stencil
Definition GraphicsContext:96
GLenum format
Definition GraphicsContext:109
std::string windowName
Definition GraphicsContext:86
unsigned int mipMapGeneration
Definition GraphicsContext:112
unsigned int alpha
Definition GraphicsContext:94
std::string glContextVersion
Definition GraphicsContext:129
Traits(DisplaySettings *ds=0)
unsigned int blue
Definition GraphicsContext:92
Simple resolution structure used by WindowingSystemInterface to get and set screen resolution.
Definition GraphicsContext:155
unsigned int colorDepth
RGB(A) color buffer depth.
Definition GraphicsContext:173
int height
Definition GraphicsContext:171
double refreshRate
Screen refresh rate, in Hz.
Definition GraphicsContext:172
ScreenSettings()
Definition GraphicsContext:156
int width
Definition GraphicsContext:170
ScreenSettings(int in_width, int in_height, double in_refreshRate=0, unsigned int in_colorDepth=0)
Definition GraphicsContext:163
Callback to be implemented to provide access to Windowing API's ability to create Windows/pbuffers.
Definition GraphicsContext:180
bool setScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int width, unsigned int height)
Sets screen resolution without using the ScreenSettings structure.
Definition GraphicsContext:210
WindowingSystemInterface()
Definition GraphicsContext:224
void setName(const std::string &name)
Definition GraphicsContext:181
std::string _name
Definition GraphicsContext:227
bool setScreenRefreshRate(const ScreenIdentifier &screenIdentifier, double refreshRate)
Definition GraphicsContext:216
virtual unsigned int getNumScreens(const ScreenIdentifier &screenIdentifier=ScreenIdentifier())=0
virtual osg::DisplaySettings * getDisplaySettings() const
Definition GraphicsContext:194
void getScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int &width, unsigned int &height)
Gets screen resolution without using the ScreenResolution structure.
Definition GraphicsContext:200
virtual void setDisplaySettings(DisplaySettings *)
Definition GraphicsContext:192
const std::string & getName() const
Definition GraphicsContext:182
virtual GraphicsContext * createGraphicsContext(Traits *traits)=0
virtual void getScreenSettings(const ScreenIdentifier &screenIdentifier, ScreenSettings &resolution)=0
virtual void enumerateScreenSettings(const ScreenIdentifier &screenIdentifier, ScreenSettingsList &resolutionList)=0
virtual bool setScreenSettings(const ScreenIdentifier &, const ScreenSettings &)
Definition GraphicsContext:188
virtual ~WindowingSystemInterface()
Definition GraphicsContext:225
WindowingSystemInterface * getWindowingSystemInterface(const std::string &name="")
get named WindowingSystemInterface if one is available, otherwise return 0;
WindowingSystemInterfaces()
Interfaces & getInterfaces()
Definition GraphicsContext:237
std::vector< osg::ref_ptr< GraphicsContext::WindowingSystemInterface > > Interfaces
Definition GraphicsContext:235
void removeWindowingSystemInterface(WindowingSystemInterface *wsInterface)
void addWindowingSystemInterface(WindowingSystemInterface *wsInterface)
Definition GraphicsContext:441
virtual void swapBuffersImplementation(GraphicsContext *gc)=0
Definition GraphicsContext:483
virtual void resizedImplementation(GraphicsContext *gc, int x, int y, int width, int height)=0
virtual void swapBuffersImplementation(GraphicsContext *gc)
GLsync _previousSync
Definition GraphicsContext:577
SyncSwapBuffersCallback()
osg::ref_ptr< T > _wsi
Definition GraphicsContext:597
WindowingSystemInterfaceProxy(const std::string &name)
Definition GraphicsContext:584
~WindowingSystemInterfaceProxy()
Definition GraphicsContext:592
GraphicsThread is a helper class for running OpenGL GraphicsOperation within a single thread assigned...
Definition GraphicsThread:26
Object()
Construct an object.
Definition Object:69
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Definition OperationThread:31
Base class for implementing graphics operations.
Definition OperationThread:51
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
static Timer * instance()
double delta_s(Timer_t t1, Timer_t t2) const
Get the time in seconds between timer ticks t1 and t2.
Definition Timer:59
#define OSG_EXPORT
Definition Export:39