Added new osg::GraphicsContext base class

This commit is contained in:
Robert Osfield
2005-07-20 15:55:07 +00:00
parent 9120a0ca2c
commit b9e651baf1
13 changed files with 96 additions and 212 deletions

View File

@@ -20,6 +20,7 @@
#include <osg/CullSettings>
#include <osg/Texture>
#include <osg/Image>
#include <osg/GraphicsContext>
namespace osg {
@@ -258,6 +259,16 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
/** Set the GraphicsContext that provides the mechansim for managing the OpenGL graphics context associated with this camera.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the GraphicsContext.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
/** Get the const GraphicsContext.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
void setRenderingCache(osg::Object* rc) { _renderingCache = rc; }
@@ -297,6 +308,7 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
RenderTargetImplementation _renderTargetImplementation;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<GraphicsContext> _graphicsContext;
ref_ptr<Object> _renderingCache;
};

View File

@@ -63,6 +63,10 @@ namespace osg {
}\
}
// forward decalr GraphicsContext
class GraphicsContext;
/** Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,.
* implements lazy state updating and provides accessors for querrying the current state.
. The venerable Red Book says that "OpenGL is a state machine", and this class
@@ -83,6 +87,32 @@ class OSG_EXPORT State : public Referenced
public :
State();
/** Set the graphics context associated with that owns this State object.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the graphics context associated with that owns this State object.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext; }
/** Get the const graphics context associated with that owns this State object.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext; }
/** Set the current OpenGL context uniqueID.
Note, it is the application developers responsibility to
set up unique ID for each OpenGL context. This value is
then used by osg::StateAttribute's and osg::Drawable's to
help manage OpenGL display list and texture binds appropriate
for each context, the contextID simply acts as an index in local
arrays that they maintain for the purpose.
Typical settings for contextID are 0,1,2,3... up to the maximum
number of graphics contexts you have set up.
By default contextID is 0.*/
inline void setContextID(unsigned int contextID) { _contextID=contextID; }
/** Get the current OpenGL context unique ID.*/
inline unsigned int getContextID() const { return _contextID; }
/** Push stateset onto state stack.*/
void pushStateSet(const StateSet* dstate);
@@ -669,21 +699,6 @@ class OSG_EXPORT State : public Referenced
inline GLint getUniformLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(name) : -1; }
inline GLint getAttribLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getAttribLocation(name) : -1; }
/** Set the current OpenGL context uniqueID.
Note, it is the application developers responsibility to
set up unique ID for each OpenGL context. This value is
then used by osg::StateAttribute's and osg::Drawable's to
help manage OpenGL display list and texture binds appropriate
for each context, the contextID simply acts as an index in local
arrays that they maintain for the purpose.
Typical settings for contextID are 0,1,2,3... up to the maximum
number of graphics contexts you have set up.
By default contextID is 0.*/
inline void setContextID(unsigned int contextID) { _contextID=contextID; }
/** Get the current OpenGL context unique ID.*/
inline unsigned int getContextID() const { return _contextID; }
/** Set the frame stamp for the current frame.*/
inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
@@ -738,6 +753,7 @@ class OSG_EXPORT State : public Referenced
virtual ~State();
GraphicsContext* _graphicsContext;
unsigned int _contextID;
ref_ptr<FrameStamp> _frameStamp;