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:
@@ -8,15 +8,19 @@
|
||||
#include <osg/Node>
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Drawable::DeletedDisplayListCache Drawable::s_deletedDisplayListCache;
|
||||
// static cache of deleted display lists which can only
|
||||
// by completely deleted once the appropriate OpenGL context
|
||||
// is set. Used osg::Drawable::deleteDisplayList(..) and flushDeletedDisplayLists(..) below.
|
||||
typedef std::map<GLuint,std::set<GLuint> > DeletedDisplayListCache;
|
||||
static DeletedDisplayListCache s_deletedDisplayListCache;
|
||||
|
||||
Drawable::Drawable()
|
||||
{
|
||||
_globjList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
|
||||
_bbox_computed = false;
|
||||
|
||||
// Note, if your are defining a subclass from drawable which is
|
||||
@@ -26,7 +30,6 @@ Drawable::Drawable()
|
||||
// dynamic updating of data.
|
||||
_supportsDisplayList = true;
|
||||
_useDisplayList = true;
|
||||
|
||||
}
|
||||
|
||||
Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
@@ -38,10 +41,10 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
_shape(copyop(drawable._shape.get())),
|
||||
_supportsDisplayList(drawable._supportsDisplayList),
|
||||
_useDisplayList(drawable._useDisplayList),
|
||||
_globjList(drawable._globjList),
|
||||
_drawCallback(drawable._drawCallback),
|
||||
_cullCallback(drawable._cullCallback)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
@@ -90,9 +93,6 @@ void Drawable::compile(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];
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <osg/Geometry>
|
||||
#include <osg/ShadeModel>
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
GeoSet::GeoSet()
|
||||
|
||||
@@ -146,15 +146,28 @@ bool Group::replaceChild( Node *origNode, Node *newNode )
|
||||
{
|
||||
if (newNode==NULL || origNode==newNode) return false;
|
||||
|
||||
ChildList::iterator itr = findNode(origNode);
|
||||
if (itr!=_children.end())
|
||||
unsigned int pos = findChildNum(origNode);
|
||||
if (pos<_children.size())
|
||||
{
|
||||
return setChild(pos,newNode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Group::setChild( unsigned int i, Node* newNode )
|
||||
{
|
||||
if (i<_children.size() && newNode)
|
||||
{
|
||||
|
||||
Node* origNode = _children[i].get();
|
||||
|
||||
// first remove for origNode's parent list.
|
||||
origNode->removeParent(this);
|
||||
|
||||
// note ref_ptr<> automatically handles decrementing origNode's reference count,
|
||||
// and inccrementing newNode's reference count.
|
||||
*itr = newNode;
|
||||
_children[i] = newNode;
|
||||
|
||||
// register as parent of child.
|
||||
newNode->addParent(this);
|
||||
|
||||
@@ -69,7 +69,7 @@ bool LOD::addChild(Node *child, float min, float max)
|
||||
bool LOD::removeChild( Node *child )
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNo(child);
|
||||
unsigned int pos=findChildNum(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
_rangeList.erase(_rangeList.begin()+pos);
|
||||
|
||||
@@ -427,6 +427,17 @@ void State::dirtyAllVertexArrays()
|
||||
dirtySecondaryColorPointer();
|
||||
}
|
||||
|
||||
void State::setInterleavedArrays( GLenum format, GLsizei stride, void* pointer)
|
||||
{
|
||||
glInterleavedArrays( format, stride, pointer);
|
||||
|
||||
// the crude way, assume that all arrays have been effected so dirty them and
|
||||
// disable them...
|
||||
dirtyAllVertexArrays();
|
||||
disableAllVertexArrays();
|
||||
}
|
||||
|
||||
|
||||
typedef void (APIENTRY * ActiveTextureProc) (GLenum texture);
|
||||
|
||||
bool State::setClientActiveTextureUnit( unsigned int unit )
|
||||
|
||||
@@ -61,7 +61,7 @@ bool Switch::addChild( Node *child, bool value )
|
||||
bool Switch::removeChild( Node *child )
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNo(child);
|
||||
unsigned int pos=findChildNum(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
_values.erase(_values.begin()+pos);
|
||||
@@ -78,7 +78,7 @@ void Switch::setValue(unsigned int pos,bool value)
|
||||
void Switch::setValue(const Node* child,bool value)
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNo(child);
|
||||
unsigned int pos=findChildNum(child);
|
||||
if (pos==_children.size()) return;
|
||||
|
||||
_values[pos]=value;
|
||||
@@ -93,7 +93,7 @@ bool Switch::getValue(unsigned int pos) const
|
||||
bool Switch::getValue(const Node* child) const
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNo(child);
|
||||
unsigned int pos=findChildNum(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
return _values[pos];
|
||||
|
||||
@@ -19,9 +19,6 @@ Texture::Texture():
|
||||
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
|
||||
_internalFormat(0)
|
||||
{
|
||||
// _handleList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
// _modifiedTag.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
// _texParametersDirtyList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),true);
|
||||
}
|
||||
|
||||
Texture::Texture(const Texture& text,const CopyOp& copyop):
|
||||
@@ -36,9 +33,6 @@ Texture::Texture(const Texture& text,const CopyOp& copyop):
|
||||
_internalFormatMode(text._internalFormatMode),
|
||||
_internalFormat(text._internalFormat)
|
||||
{
|
||||
// _handleList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
// _modifiedTag.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
// _texParametersDirtyList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),true);
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
@@ -134,7 +128,7 @@ void Texture::dirtyTextureParameters()
|
||||
{
|
||||
for(uint i=0;i<_texParametersDirtyList.size();++i)
|
||||
{
|
||||
_texParametersDirtyList[i] = 0;
|
||||
_texParametersDirtyList[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user