openscenegraph
|
#include <GraphicsContext>
Classes | |
struct | ResizedCallback |
struct | ScreenIdentifier |
struct | ScreenSettings |
struct | SwapCallback |
struct | Traits |
struct | WindowingSystemInterface |
class | WindowingSystemInterfaces |
Public Types | |
typedef std::vector< ScreenSettings > | ScreenSettingsList |
typedef std::vector< GraphicsContext * > | GraphicsContexts |
typedef std::list< ref_ptr< Operation > > | GraphicsOperationQueue |
typedef std::list< osg::Camera * > | Cameras |
![]() | |
enum | DataVariance { DYNAMIC , STATIC , UNSPECIFIED } |
Public Member Functions | |
void | add (Operation *operation) |
void | remove (Operation *operation) |
void | remove (const std::string &name) |
void | removeAllOperations () |
virtual void | runOperations () |
GraphicsOperationQueue & | getOperationsQueue () |
OpenThreads::Mutex * | getOperationsMutex () |
osg::RefBlock * | getOperationsBlock () |
Operation * | getCurrentOperation () |
const Traits * | getTraits () const |
virtual bool | valid () const =0 |
void | setState (State *state) |
State * | getState () |
const State * | getState () const |
void | setClearColor (const Vec4 &color) |
const Vec4 & | getClearColor () const |
void | setClearMask (GLbitfield mask) |
GLbitfield | getClearMask () const |
virtual void | clear () |
double | getTimeSinceLastClear () const |
bool | realize () |
void | close (bool callCloseImplementation=true) |
void | swapBuffers () |
bool | isRealized () const |
bool | makeCurrent () |
bool | makeContextCurrent (GraphicsContext *readContext) |
bool | releaseContext () |
bool | isCurrent () const |
void | bindPBufferToTexture (GLenum buffer) |
void | createGraphicsThread () |
void | setGraphicsThread (GraphicsThread *gt) |
GraphicsThread * | getGraphicsThread () |
const GraphicsThread * | getGraphicsThread () const |
virtual bool | realizeImplementation ()=0 |
virtual bool | isRealizedImplementation () const =0 |
virtual void | closeImplementation ()=0 |
virtual bool | makeCurrentImplementation ()=0 |
virtual bool | makeContextCurrentImplementation (GraphicsContext *readContext)=0 |
virtual bool | releaseContextImplementation ()=0 |
virtual void | bindPBufferToTextureImplementation (GLenum buffer)=0 |
void | setSwapCallback (SwapCallback *rc) |
SwapCallback * | getSwapCallback () |
const SwapCallback * | getSwapCallback () const |
void | swapBuffersCallbackOrImplementation () |
virtual void | swapBuffersImplementation ()=0 |
void | resized (int x, int y, int width, int height) |
void | setResizedCallback (ResizedCallback *rc) |
ResizedCallback * | getResizedCallback () |
const ResizedCallback * | getResizedCallback () const |
virtual void | resizedImplementation (int x, int y, int width, int height) |
Cameras & | getCameras () |
const Cameras & | getCameras () const |
void | setDefaultFboId (GLuint i) |
GLuint | getDefaultFboId () const |
virtual bool | isSameKindAs (const Object *object) const |
virtual const char * | libraryName () const |
virtual const char * | className () const |
![]() | |
Object () | |
Object (bool threadSafeRefUnref) | |
Object (const Object &, const CopyOp ©op=CopyOp::SHALLOW_COPY) | |
std::string | getCompoundClassName () const |
virtual Node * | asNode () |
virtual const Node * | asNode () const |
virtual NodeVisitor * | asNodeVisitor () |
virtual const NodeVisitor * | asNodeVisitor () const |
virtual StateSet * | asStateSet () |
virtual const StateSet * | asStateSet () const |
virtual StateAttribute * | asStateAttribute () |
virtual const StateAttribute * | asStateAttribute () const |
virtual Uniform * | asUniform () |
virtual const Uniform * | asUniform () const |
virtual Camera * | asCamera () |
virtual const Camera * | asCamera () const |
virtual Drawable * | asDrawable () |
virtual const Drawable * | asDrawable () const |
virtual Callback * | asCallback () |
virtual const Callback * | asCallback () const |
virtual CallbackObject * | asCallbackObject () |
virtual const CallbackObject * | asCallbackObject () const |
virtual UserDataContainer * | asUserDataContainer () |
virtual const UserDataContainer * | asUserDataContainer () const |
virtual ValueObject * | asValueObject () |
virtual const ValueObject * | asValueObject () const |
virtual Image * | asImage () |
virtual const Image * | asImage () const |
virtual void | setThreadSafeRefUnref (bool threadSafe) |
virtual void | setName (const std::string &name) |
void | setName (const char *name) |
const std::string & | getName () const |
void | setDataVariance (DataVariance dv) |
DataVariance | getDataVariance () const |
virtual void | computeDataVariance () |
void | setUserDataContainer (osg::UserDataContainer *udc) |
template<class T > | |
void | setUserDataContainer (const ref_ptr< T > &udc) |
osg::UserDataContainer * | getUserDataContainer () |
const osg::UserDataContainer * | getUserDataContainer () const |
osg::UserDataContainer * | getOrCreateUserDataContainer () |
virtual void | setUserData (Referenced *obj) |
template<class T > | |
void | setUserData (const ref_ptr< T > &ud) |
virtual Referenced * | getUserData () |
virtual const Referenced * | getUserData () const |
template<typename T > | |
bool | getUserValue (const std::string &name, T &value) const |
template<typename T > | |
void | setUserValue (const std::string &name, const T &value) |
virtual void | resizeGLObjectBuffers (unsigned int) |
virtual void | releaseGLObjects (osg::State *=0) const |
template<typename T > | |
BoolValueObject UCharValueObject UShortValueObject UIntValueObject DoubleValueObject Vec3fValueObject Vec2dValueObject Vec4dValueObject PlaneValueObject MatrixdValueObject BoundingBoxdValueObject BoundingSpheredValueObject bool | getUserValue (const std::string &name, T &value) const |
![]() | |
Referenced () | |
Referenced (bool threadSafeRefUnref) | |
Referenced (const Referenced &) | |
Referenced & | operator= (const Referenced &) |
bool | getThreadSafeRefUnref () const |
OpenThreads::Mutex * | getRefMutex () const |
int | ref () const |
int | unref () const |
int | unref_nodelete () const |
int | referenceCount () const |
ObserverSet * | getObserverSet () const |
ObserverSet * | getOrCreateObserverSet () const |
void | addObserver (Observer *observer) const |
void | removeObserver (Observer *observer) const |
Protected Member Functions | |
GraphicsContext () | |
GraphicsContext (const GraphicsContext &, const osg::CopyOp &) | |
virtual | ~GraphicsContext () |
virtual Object * | cloneType () const |
virtual Object * | clone (const CopyOp &) const |
void | addCamera (osg::Camera *camera) |
void | removeCamera (osg::Camera *camera) |
![]() | |
virtual | ~Object () |
![]() | |
virtual | ~Referenced () |
void | signalObserversAndDelete (bool signalDelete, bool doDelete) const |
void | deleteUsingDeleteHandler () const |
Static Protected Member Functions | |
static void | registerGraphicsContext (GraphicsContext *gc) |
static void | unregisterGraphicsContext (GraphicsContext *gc) |
Protected Attributes | |
Cameras | _cameras |
ref_ptr< Traits > | _traits |
ref_ptr< State > | _state |
Vec4 | _clearColor |
GLbitfield | _clearMask |
size_t | _threadOfLastMakeCurrent |
OpenThreads::Mutex | _operationsMutex |
osg::ref_ptr< osg::RefBlock > | _operationsBlock |
GraphicsOperationQueue | _operations |
osg::ref_ptr< Operation > | _currentOperation |
ref_ptr< GraphicsThread > | _graphicsThread |
ref_ptr< ResizedCallback > | _resizedCallback |
ref_ptr< SwapCallback > | _swapCallback |
Timer_t | _lastClearTick |
GLuint | _defaultFboId |
![]() | |
std::string | _name |
DataVariance | _dataVariance |
osg::UserDataContainer * | _userDataContainer |
![]() | |
OpenThreads::AtomicPtr | _observerSet |
OpenThreads::Atomic | _refCount |
Friends | |
class | osg::Camera |
Base class for providing Windowing API agnostic access to creating and managing graphics context.
typedef std::list< osg::Camera* > osg::GraphicsContext::Cameras |
typedef std::vector<GraphicsContext*> osg::GraphicsContext::GraphicsContexts |
typedef std::list< ref_ptr<Operation> > osg::GraphicsContext::GraphicsOperationQueue |
typedef std::vector<ScreenSettings> osg::GraphicsContext::ScreenSettingsList |
|
protected |
|
protected |
|
protectedvirtual |
void osg::GraphicsContext::add | ( | Operation * | operation | ) |
Add operation to end of OperationQueue.
|
protected |
|
inline |
Bind the graphics context to associated texture.
|
pure virtual |
Pure virtual, Bind the graphics context to associated texture implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::PixelBufferX11, osgViewer::PixelBufferWin32, and osgViewer::GraphicsWindow.
|
inlinevirtual |
return the name of the object's class type. Must be defined by derived classes.
Implements osg::Object.
Reimplemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
virtual |
Do an OpenGL clear of the full graphics context/window. Note, must only be called from a thread with this context current.
Clone an object, with Object* return type. Must be defined by derived classes.
Implements osg::Object.
|
inlineprotectedvirtual |
Clone the type of an object, with Object* return type. Must be defined by derived classes.
Implements osg::Object.
void osg::GraphicsContext::close | ( | bool | callCloseImplementation = true | ) |
close the graphics context. close(bool) stops any associated graphics threads, releases the contextID for the GraphicsContext then optional calls closeImplementation() to do the actual deletion of the graphics. This call is made optional as there are times when the graphics context has already been deleted externally and only the OSG side of the its data need to be closed down.
|
pure virtual |
Close the graphics context implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
static |
Create a graphics context for a specified set of traits.
void osg::GraphicsContext::createGraphicsThread | ( | ) |
Create a graphics thread to the graphics context, so that the thread handles all OpenGL operations.
|
static |
Create a contextID for a new graphics context, this contextID is used to set up the osg::State associate with context. Automatically increments the usage count of the contextID to 1.
|
static |
Decrement the usage count associate with a contextID. Once the contextID goes to 0 the contextID is then free to be reused.
|
static |
Get all the registered graphics contexts.
|
inline |
Get the list of cameras associated with this graphics context.
|
inline |
Get the const list of cameras associated with this graphics context.
|
inline |
Returns the clear color.
|
inline |
Get the clear mask.
|
static |
Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.
|
inline |
Get the current operations that is being run.
|
inline |
|
inline |
Get the graphics thread assigned the graphics context.
|
inline |
Get the const graphics thread assigned the graphics context.
|
static |
Get the current max ContextID.
|
inline |
Get the operations queue block used to mark an empty queue, if you end items into the empty queue you must release this block.
|
inline |
Get the operations queue mutex.
|
inline |
Get the operations queue, note you must use the OperationsMutex when accessing the queue.
|
static |
Get existing or create a new GraphicsContext to do background compilation for GraphicsContexts associated with specified contextID.
|
static |
Get all the registered graphics contexts associated with a specific contextID.
|
inline |
Get the resized callback which overrides the GraphicsConext::realizedImplementation().
|
inline |
Get the const resized callback which overrides the GraphicsConext::realizedImplementation().
|
inline |
Get the State object which tracks the current OpenGL state for this graphics context.
|
inline |
Get the const State object which tracks the current OpenGL state for this graphics context.
|
inline |
Get the swap callback which overrides the GraphicsContext::swapBuffersImplementation().
|
inline |
Get the const swap callback which overrides the GraphicsContext::swapBuffersImplementation().
|
inline |
|
inline |
Get the traits of the GraphicsContext.
|
static |
Get the default WindowingSystemInterface for this OS
|
static |
|
static |
Increment the usage count associate with a contextID. The usage count specifies how many graphics contexts a specific contextID is shared between.
|
inline |
Return true if the current thread has this OpenGL graphics context.
|
inline |
Return true if the graphics context has been realized and is ready to use.
|
pure virtual |
Return true if the graphics context has been realized, and is ready to use, implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
inlinevirtual |
Reimplemented from osg::Object.
|
inlinevirtual |
return the name of the object's library. Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name.
Implements osg::Object.
Reimplemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
bool osg::GraphicsContext::makeContextCurrent | ( | GraphicsContext * | readContext | ) |
Make this graphics context current with specified read context. Implemented by calling makeContextCurrentImplementation(). Returns true on success.
|
pure virtual |
Make this graphics context current with specified read context implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::PixelBufferX11.
bool osg::GraphicsContext::makeCurrent | ( | ) |
Make this graphics context current. Implemented by calling makeCurrentImplementation(). Returns true on success.
|
pure virtual |
Make this graphics context current implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
bool osg::GraphicsContext::realize | ( | ) |
Realize the GraphicsContext.
|
pure virtual |
Realize the GraphicsContext implementation, Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
staticprotected |
Register a GraphicsContext.
bool osg::GraphicsContext::releaseContext | ( | ) |
Release the graphics context. Returns true on success.
|
pure virtual |
Release the graphics context implementation.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
void osg::GraphicsContext::remove | ( | const std::string & | name | ) |
Remove named operation from OperationQueue.
void osg::GraphicsContext::remove | ( | Operation * | operation | ) |
Remove operation from OperationQueue.
void osg::GraphicsContext::removeAllOperations | ( | ) |
Remove all operations from OperationQueue.
|
protected |
|
inline |
resized method should be called when the underlying window has been resized and the GraphicsWindow and associated Cameras must be updated to keep in sync with the new size.
|
virtual |
resized implementation, by default resizes the viewports and aspect ratios the cameras associated with the graphics Window.
|
virtual |
Run the operations.
|
inline |
Sets the clear color.
|
inline |
Set the clear mask used in glClear(..). Defaults to 0 - so no clear is done by default by the GraphicsContext, instead the Cameras attached to the GraphicsContext will do the clear. GraphicsContext::setClearMask() is useful for when the Camera Viewports don't cover the whole context, so the context will fill in the gaps.
|
static |
Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.
|
inline |
set the default FBO-id, this id will be used when the rendering-backend is finished with RTT FBOs
void osg::GraphicsContext::setGraphicsThread | ( | GraphicsThread * | gt | ) |
Assign a graphics thread to the graphics context, so that the thread handles all OpenGL operations.
|
inline |
Set the resized callback which overrides the GraphicsConext::realizedImplementation(), allow developers to provide custom behavior in response to a window being resized.
|
inline |
Set the State object which tracks the current OpenGL state for this graphics context.
|
inline |
Set the swap callback which overrides the GraphicsContext::swapBuffersImplementation(), allowing developers to provide custom behavior for swap. The callback must call GraphicsContext::swapBuffersImplementation()
void osg::GraphicsContext::swapBuffers | ( | ) |
swap the front and back buffers.
|
inline |
Convenience method for handling whether to call swapbuffers callback or the standard context swapBuffersImplementation. swapBuffersCallbackOrImplementation() is called by swapBuffers() and osg::SwapBuffersOperation, end users should normally call swapBuffers() rather than swapBuffersCallbackOrImplementation().
|
pure virtual |
Swap the front and back buffers implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
staticprotected |
Unregister a GraphicsContext.
|
pure virtual |
Return whether a valid and usable GraphicsContext has been created.
Implemented in osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osgViewer::GraphicsWindowX11, osgViewer::PixelBufferX11, osgViewer::GraphicsWindow, and osgViewer::GraphicsWindowEmbedded.
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |