Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends

osg::GraphicsContext Class Reference

Inheritance diagram for osg::GraphicsContext:
osg::Object osg::Referenced osgViewer::GraphicsWindow osgViewer::PixelBufferWin32 osgViewer::PixelBufferX11 osgViewer::GraphicsWindowEmbedded osgViewer::GraphicsWindowWin32 osgViewer::GraphicsWindowX11

List of all members.

Classes

struct  ResizedCallback
struct  ScreenIdentifier
struct  ScreenSettings
struct  Traits
struct  WindowingSystemInterface

Public Types

typedef std::vector
< ScreenSettings
ScreenSettingsList
typedef std::vector
< GraphicsContext * > 
GraphicsContexts
typedef std::list< ref_ptr
< Operation > > 
OperationQueue
typedef std::list< osg::Camera * > Cameras

Public Member Functions

void add (Operation *operation)
void remove (Operation *operation)
void remove (const std::string &name)
void removeAllOperations ()
void runOperations ()
OperationQueuegetOperationsQueue ()
OpenThreads::MutexgetOperationsMutex ()
osg::RefBlockgetOperationsBlock ()
OperationgetCurrentOperation ()
const TraitsgetTraits () const
virtual bool valid () const =0
void setState (State *state)
StategetState ()
const StategetState () const
void setClearColor (const Vec4 &color)
const Vec4getClearColor () const
void setClearMask (GLbitfield mask)
GLbitfield getClearMask () const
virtual void clear ()
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)
GraphicsThreadgetGraphicsThread ()
const GraphicsThreadgetGraphicsThread () 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
virtual void swapBuffersImplementation ()=0
void resized (int x, int y, int width, int height)
void setResizedCallback (ResizedCallback *rc)
ResizedCallbackgetResizedCallback ()
const ResizedCallbackgetResizedCallback () const
virtual void resizedImplementation (int x, int y, int width, int height)
CamerasgetCameras ()
const CamerasgetCameras () const
virtual bool isSameKindAs (const Object *object) const
virtual const char * libraryName () const
virtual const char * className () const

Static Public Member Functions

static void setWindowingSystemInterface (WindowingSystemInterface *wsInterface)
static WindowingSystemInterfacegetWindowingSystemInterface ()
static GraphicsContextcreateGraphicsContext (Traits *traits)
static unsigned int createNewContextID ()
static unsigned int getMaxContextID ()
static void incrementContextIDUsageCount (unsigned int contextID)
static void decrementContextIDUsageCount (unsigned int contextID)
static GraphicsContexts getAllRegisteredGraphicsContexts ()
static GraphicsContexts getRegisteredGraphicsContexts (unsigned int contextID)
static void setCompileContext (unsigned int contextID, GraphicsContext *gc)
static GraphicsContextgetOrCreateCompileContext (unsigned int contextID)
static GraphicsContextgetCompileContext (unsigned int contextID)

Protected Member Functions

 GraphicsContext ()
 GraphicsContext (const GraphicsContext &, const osg::CopyOp &)
virtual ~GraphicsContext ()
virtual ObjectcloneType () const
virtual Objectclone (const CopyOp &) const
void addCamera (osg::Camera *camera)
void removeCamera (osg::Camera *camera)

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
OpenThreads::Thread_threadOfLastMakeCurrent
OpenThreads::Mutex _operationsMutex
osg::ref_ptr< osg::RefBlock_operationsBlock
OperationQueue _operations
osg::ref_ptr< Operation_currentOperation
ref_ptr< GraphicsThread_graphicsThread
ref_ptr< ResizedCallback_resizedCallback

Friends

class osg::Camera

Detailed Description

Base class for providing Windowing API agnostic access to creating and managing graphics context.


Member Typedef Documentation


Constructor & Destructor Documentation

osg::GraphicsContext::GraphicsContext (  )  [protected]
osg::GraphicsContext::GraphicsContext ( const GraphicsContext ,
const osg::CopyOp  
) [protected]
virtual osg::GraphicsContext::~GraphicsContext (  )  [protected, virtual]

Member Function Documentation

void osg::GraphicsContext::add ( Operation operation  ) 

Add operation to end of OperationQueue.

void osg::GraphicsContext::addCamera ( osg::Camera camera  )  [protected]
void osg::GraphicsContext::bindPBufferToTexture ( GLenum  buffer  )  [inline]

Bind the graphics context to associated texture.

virtual void osg::GraphicsContext::bindPBufferToTextureImplementation ( GLenum  buffer  )  [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::PixelBufferWin32, and osgViewer::PixelBufferX11.

virtual const char* osg::GraphicsContext::className (  )  const [inline, virtual]

return the name of the object's class type. Must be defined by derived classes.

Implements osg::Object.

Reimplemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

virtual void osg::GraphicsContext::clear (  )  [virtual]

Do an OpenGL clear of the full graphics context/window. Note, must only be called from a thread with this context current.

virtual Object* osg::GraphicsContext::clone ( const CopyOp  )  const [inline, protected, virtual]

Clone an object, with Object* return type. Must be defined by derived classes.

Implements osg::Object.

virtual Object* osg::GraphicsContext::cloneType (  )  const [inline, protected, virtual]

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.

virtual void osg::GraphicsContext::closeImplementation (  )  [pure virtual]

Close the graphics context implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

static GraphicsContext* osg::GraphicsContext::createGraphicsContext ( Traits traits  )  [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 unsigned int osg::GraphicsContext::createNewContextID (  )  [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.

Referenced by osgViewer::GraphicsWindowX11::GraphicsWindowX11(), and osgViewer::GraphicsWindowEmbedded::init().

static void osg::GraphicsContext::decrementContextIDUsageCount ( unsigned int  contextID  )  [static]

Decrement the usage count associate with a contextID. Once the contextID goes to 0 the contextID is then free to be reused.

static GraphicsContexts osg::GraphicsContext::getAllRegisteredGraphicsContexts (  )  [static]

Get all the registered graphics contexts.

Cameras& osg::GraphicsContext::getCameras (  )  [inline]

Get the the list of cameras associated with this graphics context.

const Cameras& osg::GraphicsContext::getCameras (  )  const [inline]

Get the the const list of cameras associated with this graphics context.

const Vec4& osg::GraphicsContext::getClearColor (  )  const [inline]

Returns the clear color.

GLbitfield osg::GraphicsContext::getClearMask (  )  const [inline]

Get the clear mask.

static GraphicsContext* osg::GraphicsContext::getCompileContext ( unsigned int  contextID  )  [static]

Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.

Operation* osg::GraphicsContext::getCurrentOperation (  )  [inline]

Get the current operations that is being run.

GraphicsThread* osg::GraphicsContext::getGraphicsThread (  )  [inline]

Get the graphics thread assigned the graphics context.

const GraphicsThread* osg::GraphicsContext::getGraphicsThread (  )  const [inline]

Get the const graphics thread assigned the graphics context.

static unsigned int osg::GraphicsContext::getMaxContextID (  )  [static]

Get the current max ContextID.

osg::RefBlock* osg::GraphicsContext::getOperationsBlock (  )  [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.

OpenThreads::Mutex* osg::GraphicsContext::getOperationsMutex (  )  [inline]

Get the operations queue mutex.

OperationQueue& osg::GraphicsContext::getOperationsQueue (  )  [inline]

Get the operations queue, not you must use the OperationsMutex when accessing the queue.

static GraphicsContext* osg::GraphicsContext::getOrCreateCompileContext ( unsigned int  contextID  )  [static]

Get existing or create a new GraphicsContext to do background compilation for GraphicsContexts associated with specified contextID.

static GraphicsContexts osg::GraphicsContext::getRegisteredGraphicsContexts ( unsigned int  contextID  )  [static]

Get all the registered graphics contexts associated with a specific contextID.

ResizedCallback* osg::GraphicsContext::getResizedCallback (  )  [inline]

Get the resized callback which overrides the GraphicsConext::realizedImplementation().

const ResizedCallback* osg::GraphicsContext::getResizedCallback (  )  const [inline]

Get the const resized callback which overrides the GraphicsConext::realizedImplementation().

State* osg::GraphicsContext::getState (  )  [inline]

Get the State object which tracks the current OpenGL state for this graphics context.

Referenced by osgViewer::GraphicsWindowEmbedded::init().

const State* osg::GraphicsContext::getState (  )  const [inline]

Get the const State object which tracks the current OpenGL state for this graphics context.

const Traits* osg::GraphicsContext::getTraits (  )  const [inline]

Get the traits of the GraphicsContext.

static WindowingSystemInterface* osg::GraphicsContext::getWindowingSystemInterface (  )  [static]
static void osg::GraphicsContext::incrementContextIDUsageCount ( unsigned int  contextID  )  [static]

Increment the usage count associate with a contextID. The usage count specifies how many graphics contexts a specific contextID is shared between.

Referenced by osgViewer::GraphicsWindowEmbedded::init().

bool osg::GraphicsContext::isCurrent (  )  const [inline]

Return true if the current thread has this OpenGL graphics context.

References OpenThreads::Thread::CurrentThread().

bool osg::GraphicsContext::isRealized (  )  const [inline]

Return true if the graphics context has been realized and is ready to use.

virtual bool osg::GraphicsContext::isRealizedImplementation (  )  const [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::PixelBufferWin32, and osgViewer::PixelBufferX11.

virtual bool osg::GraphicsContext::isSameKindAs ( const Object object  )  const [inline, virtual]

Reimplemented from osg::Object.

virtual const char* osg::GraphicsContext::libraryName (  )  const [inline, virtual]

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::PixelBufferWin32, and osgViewer::PixelBufferX11.

bool osg::GraphicsContext::makeContextCurrent ( GraphicsContext readContext  ) 

Make this graphics context current with specified read context. Implemented by calling makeContextCurrentImplementation(). Returns true on success.

virtual bool osg::GraphicsContext::makeContextCurrentImplementation ( GraphicsContext readContext  )  [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.

Referenced by osgViewer::ViewerBase::makeCurrent().

virtual bool osg::GraphicsContext::makeCurrentImplementation (  )  [pure virtual]

Make this graphics context current implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

bool osg::GraphicsContext::realize (  ) 

Realize the GraphicsContext.

virtual bool osg::GraphicsContext::realizeImplementation (  )  [pure virtual]

Realize the GraphicsContext implementation, Pure virtual - must be implemented by concrete implementations of GraphicsContext.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

static void osg::GraphicsContext::registerGraphicsContext ( GraphicsContext gc  )  [static, protected]

Register a GraphicsContext.

bool osg::GraphicsContext::releaseContext (  ) 

Release the graphics context. Returns true on success.

Referenced by osgViewer::ViewerBase::releaseContext().

virtual bool osg::GraphicsContext::releaseContextImplementation (  )  [pure virtual]

Release the graphics context implementation.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

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.

void osg::GraphicsContext::removeCamera ( osg::Camera camera  )  [protected]
void osg::GraphicsContext::resized ( int  x,
int  y,
int  width,
int  height 
) [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 void osg::GraphicsContext::resizedImplementation ( int  x,
int  y,
int  width,
int  height 
) [virtual]

resized implementation, by default resizes the viewports and aspect ratios the cameras associated with the graphics Window.

void osg::GraphicsContext::runOperations (  ) 

Run the operations.

void osg::GraphicsContext::setClearColor ( const Vec4 color  )  [inline]

Sets the clear color.

void osg::GraphicsContext::setClearMask ( GLbitfield  mask  )  [inline]

Set the clear mask used in glClear(..). Defaults to 0 - so no clear is done by default by the GraphicsContext, instead the Camera's attached the GraphicsContext will do the clear. GraphicsContext::setClearMask() is useful for when the Camera's Viewports don't conver the whole context, so the context will fill in the gaps.

static void osg::GraphicsContext::setCompileContext ( unsigned int  contextID,
GraphicsContext gc 
) [static]

Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.

void osg::GraphicsContext::setGraphicsThread ( GraphicsThread gt  ) 

Assign a graphics thread to the graphics context, so that the thread handles all OpenGL operations.

void osg::GraphicsContext::setResizedCallback ( ResizedCallback rc  )  [inline]

Set the resized callback which overrides the GraphicsConext::realizedImplementation(), allow developers to provide custom behavior in response to a window being resized.

void osg::GraphicsContext::setState ( State state  )  [inline]

Set the State object which tracks the current OpenGL state for this graphics context.

Referenced by osgViewer::GraphicsWindowEmbedded::init().

static void osg::GraphicsContext::setWindowingSystemInterface ( WindowingSystemInterface wsInterface  )  [static]

Set the query the windowing system for screens and create graphics context - this functor should be supplied by the windows toolkit.

void osg::GraphicsContext::swapBuffers (  ) 

swap the front and back buffers.

virtual void osg::GraphicsContext::swapBuffersImplementation (  )  [pure virtual]

Swap the front and back buffers implementation. Pure virtual - must be implemented by concrete implementations of GraphicsContext.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

static void osg::GraphicsContext::unregisterGraphicsContext ( GraphicsContext gc  )  [static, protected]

Unregister a GraphicsContext.

virtual bool osg::GraphicsContext::valid (  )  const [pure virtual]

Return whether a valid and usable GraphicsContext has been created.

Implemented in osgViewer::PixelBufferWin32, and osgViewer::PixelBufferX11.

Referenced by osgViewer::ViewerBase::makeCurrent().


Friends And Related Function Documentation

friend class osg::Camera [friend]

Member Data Documentation

GLbitfield osg::GraphicsContext::_clearMask [protected]

The documentation for this class was generated from the following file: