Added support for multiple graphics context to osg::VertexProgram and osg::Impostor

This commit is contained in:
Robert Osfield
2003-04-10 12:11:40 +00:00
parent 0dd724e8b7
commit 22546b8085
7 changed files with 67 additions and 39 deletions

View File

@@ -16,6 +16,7 @@
#include <osg/LOD>
#include <osg/ImpostorSprite>
#include <osg/buffered_value>
namespace osg {
@@ -64,7 +65,6 @@ class SG_EXPORT Impostor : public LOD
Impostor(const Impostor& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
LOD(es,copyop),
_impostorSpriteList(),
_impostorThreshold(es._impostorThreshold) {}
META_Node(osg, Impostor);
@@ -87,16 +87,16 @@ class SG_EXPORT Impostor : public LOD
inline float getImpostorThreshold2() const { return _impostorThreshold*_impostorThreshold; }
/** Find the ImposterSprite which fits the current eye point best.*/
ImpostorSprite* findBestImpostorSprite(const osg::Vec3& currLocalEyePoint);
ImpostorSprite* findBestImpostorSprite(unsigned int contextID, const osg::Vec3& currLocalEyePoint) const;
/** Add an ImpostorSprite to the Impostor.*/
void addImpostorSprite(ImpostorSprite* is);
void addImpostorSprite(unsigned int contextID, ImpostorSprite* is);
/** Get the list of ImpostorSprites attached to this Impostor.*/
inline ImpostorSpriteList& getImpostorSpriteList() { return _impostorSpriteList; }
inline ImpostorSpriteList& getImpostorSpriteList(unsigned int contexID) { return _impostorSpriteListBuffer[contexID]; }
/** Get a const list of ImpostorSprites attached to this const Impostor.*/
inline const ImpostorSpriteList& getImpostorSpriteList() const { return _impostorSpriteList; }
inline const ImpostorSpriteList& getImpostorSpriteList(unsigned int contexID) const { return _impostorSpriteListBuffer[contexID]; }
protected :
@@ -104,7 +104,7 @@ class SG_EXPORT Impostor : public LOD
virtual bool computeBound() const;
ImpostorSpriteList _impostorSpriteList;
mutable buffered_object<ImpostorSpriteList> _impostorSpriteListBuffer;
float _impostorThreshold;

View File

@@ -202,17 +202,15 @@ class SG_EXPORT Texture : public osg::StateAttribute
/** Get the handle to the texture object for the current context.*/
/** return the OpenGL texture object for specified context.*/
inline GLuint& getTextureObject(unsigned int contextID) const
{
// get the globj for the current contextID.
return _handleList[contextID];
}
/** get the dirty flag for the current contextID.*/
inline unsigned int& getTextureParameterDirty(unsigned int contextID) const
{
// get the dirty flag for the current contextID.
return _texParametersDirtyList[contextID];
}

View File

@@ -17,6 +17,7 @@
#include <osg/StateAttribute>
#include <osg/Vec4>
#include <osg/Matrix>
#include <osg/buffered_value>
#include <map>
#include <string>
@@ -130,7 +131,7 @@ class SG_EXPORT VertexProgram : public StateAttribute
COMPARE_StateAttribute_Types(VertexProgram,sa)
// compare each paramter in turn against the rhs.
COMPARE_StateAttribute_Parameter(_vertexProgramId)
COMPARE_StateAttribute_Parameter(_vertexProgram)
return 0; // passed all the above comparison macro's, must be equal.
}
@@ -142,6 +143,12 @@ class SG_EXPORT VertexProgram : public StateAttribute
// data access methods.
/** Get the handle to the vertex program id for the current context.*/
inline GLuint& getVertexProgramID(unsigned int contextID) const
{
return _vertexProgramIDList[contextID];
}
/** Set the vertex program using C++ style string.*/
inline void setVertexProgram( const std::string& program ) { _vertexProgram = program; }
/** Set the vertex program using a C style string.*/
@@ -168,7 +175,9 @@ class SG_EXPORT VertexProgram : public StateAttribute
virtual ~VertexProgram();
mutable GLuint _vertexProgramId;
typedef buffered_value<GLuint> VertexProgramIDList;
mutable VertexProgramIDList _vertexProgramIDList;
std::string _vertexProgram;
typedef std::map<GLuint,Vec4> LocalParamList;