Moved Drawable across to using osg::buffered_value.

Added new osg::State::setInterleavedArray() method.

Added new osg::Group::setNode(uint,Node*) method.

Cleaned up and fixed the osg::Texture's handling of dirtyTextureParamters().
This commit is contained in:
Robert Osfield
2002-11-19 10:56:59 +00:00
parent 42fb3c5987
commit 5fca8ea229
11 changed files with 68 additions and 82 deletions

View File

@@ -10,10 +10,7 @@
#include <osg/Types>
#include <osg/NodeVisitor>
#include <osg/Shape>
#include <vector>
#include <map>
#include <set>
#include <osg/buffered_value>
namespace osg {
@@ -381,18 +378,13 @@ class SG_EXPORT Drawable : public Object
bool _supportsDisplayList;
bool _useDisplayList;
typedef std::vector<uint> GLObjectList;
typedef osg::buffered_value<uint> GLObjectList;
mutable GLObjectList _globjList;
ref_ptr<AppCallback> _appCallback;
ref_ptr<DrawCallback> _drawCallback;
ref_ptr<CullCallback> _cullCallback;
// static cache of deleted display lists which can only
// by completely deleted once the appropriate OpenGL context
// is set.
typedef std::map<uint,std::set<uint> > DeletedDisplayListCache;
static DeletedDisplayListCache s_deletedDisplayListCache;
};
@@ -405,9 +397,6 @@ inline void Drawable::draw(State& state)
// current OpenGL context.
uint contextID = state.getContextID();
// fill in array if required.
while (_globjList.size()<=contextID) _globjList.push_back(0);
// get the globj for the current contextID.
uint& globj = _globjList[contextID];

View File

@@ -50,23 +50,29 @@ class SG_EXPORT Group : public Node
virtual bool removeChild( Node *child );
/** Replace specified Node with another Node.
* Decrement the reference count origNode and increments the
* Equivalent to setChild(findChildNum(orignChild),node),
* see docs for setChild for futher details on implementation.*/
virtual bool replaceChild( Node *origChild, Node* newChild );
/** return the number of chilren nodes.*/
inline unsigned int getNumChildren() const { return _children.size(); }
/** set child node at position i.
* return true if set correctly, false on failure (if node==NULL || i is out of range).
* When set can be successful applied, the algorithm is : decrement the reference count origNode and increments the
* reference count of newNode, and dirty the bounding sphere
* to force it to recompute on next getBound() and returns true.
* If origNode is not found then return false and do not
* add newNode. If newNode is NULL then return false and do
* not remove origNode. Also returns false if newChild is a Scene node.
*/
virtual bool replaceChild( Node *origChild, Node* newChild );
/** return the number of chilren nodes.*/
inline unsigned int getNumChildren() const { return _children.size(); }
virtual bool setChild( unsigned int i, Node* node );
/** return child node at position i.*/
inline Node *getChild( unsigned int i ) { return _children[i].get(); }
inline Node* getChild( unsigned int i ) { return _children[i].get(); }
/** return child node at position i.*/
inline const Node *getChild( unsigned int i ) const { return _children[i].get(); }
inline const Node* getChild( unsigned int i ) const { return _children[i].get(); }
/** return true if node is contained within Group.*/
inline bool containsNode( const Node* node ) const
@@ -113,11 +119,11 @@ class SG_EXPORT Group : public Node
/** Find the index number of child, return a value between
* 0 and _children.size()-1 if found, if not found then
* return _children.size().*/
inline unsigned int findChildNo( const Node* node ) const
inline unsigned int findChildNum( const Node* node ) const
{
for (unsigned int childNo=0;childNo<_children.size();++childNo)
for (unsigned int childNum=0;childNum<_children.size();++childNum)
{
if (_children[childNo]==node) return childNo;
if (_children[childNum]==node) return childNum;
}
return _children.size(); // node not found.
}

View File

@@ -221,6 +221,13 @@ class SG_EXPORT State : public Referenced
/** dirty the vertex, normal, color, tex coords, secenday color, fog coord and index arrays.*/
void dirtyAllVertexArrays();
/** Wrapper around glInterleavedArrays(..).
* also resets the internal array points and modes within osg::State to keep the other
* vertex array operations consistent. */
void setInterleavedArrays( GLenum format, GLsizei stride, void* pointer);
/** wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(..);
* note, only updates values that change.*/
inline void setVertexPointer( GLint size, GLenum type,

View File

@@ -176,39 +176,6 @@ class SG_EXPORT Texture : public osg::StateAttribute
bool isCompressedInternalFormat() const;
// /** Get the handle to the texture object for the current context.*/
// /** return the OpenGL texture object for specified context.*/
// inline GLuint& getTextureObject(uint contextID) const
// {
// // pad out handle list if required.
// if (_handleList.size()<=contextID)
// _handleList.resize(contextID+1,0);
//
// // get the globj for the current contextID.
// return _handleList[contextID];
// }
//
// inline uint& getModifiedTag(uint contextID) const
// {
// // pad out handle list if required.
// if (_modifiedTag.size()<=contextID)
// _modifiedTag.resize(contextID+1,0);
//
// // get the modified tag for the current contextID.
// return _modifiedTag[contextID];
// }
//
// inline uint& getTextureParameterDirty(uint contextID) const
// {
// // pad out handle list if required.
// if (_texParametersDirtyList.size()<=contextID)
// _texParametersDirtyList.resize(contextID+1,0);
//
// // get the dirty flag for the current contextID.
// return _texParametersDirtyList[contextID];
// }
/** Get the handle to the texture object for the current context.*/
/** return the OpenGL texture object for specified context.*/
@@ -330,15 +297,12 @@ class SG_EXPORT Texture : public osg::StateAttribute
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
int compareTexture(const Texture& rhs) const;
// typedef std::vector<GLuint> TextureNameList;
typedef buffered_value<GLuint> TextureNameList;
mutable TextureNameList _handleList;
// typedef std::vector<uint> ImageModifiedTag;
typedef buffered_value<uint> ImageModifiedTag;
mutable ImageModifiedTag _modifiedTag;
// typedef std::vector<uint> TexParameterDirtyList;
typedef buffered_value<uint> TexParameterDirtyList;
mutable TexParameterDirtyList _texParametersDirtyList;