Work on supporting multitexturing in State/StateSet/StateAttribute/Geoemtry.
This commit is contained in:
@@ -268,9 +268,9 @@ class SG_EXPORT Drawable : public Object
|
||||
virtual void setVertexArray(unsigned int count,Vec3* vertices) = 0;
|
||||
|
||||
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned char* indices) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned short* indices) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned int* indices) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLubyte* indices) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLushort* indices) = 0;
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLuint* indices) = 0;
|
||||
|
||||
virtual void begin(GLenum mode) = 0;
|
||||
virtual void vertex(const Vec3& vert) = 0;
|
||||
@@ -460,7 +460,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned char* indices)
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLubyte* indices)
|
||||
{
|
||||
if (indices==0 || count==0) return;
|
||||
|
||||
@@ -527,7 +527,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned short* indices)
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLushort* indices)
|
||||
{
|
||||
if (indices==0 || count==0) return;
|
||||
|
||||
@@ -596,7 +596,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum mode,GLsizei count,unsigned int* indices)
|
||||
virtual void drawElements(GLenum mode,GLsizei count,GLuint* indices)
|
||||
{
|
||||
if (indices==0 || count==0) return;
|
||||
|
||||
|
||||
@@ -17,9 +17,10 @@ class Primitive : public Object
|
||||
{
|
||||
PrimitiveType,
|
||||
DrawArraysPrimitiveType,
|
||||
UByteDrawElementsPrimitiveType,
|
||||
UShortDrawElementsPrimitiveType,
|
||||
UIntDrawElementsPrimitiveType
|
||||
DrawArrayLengthsPrimitiveType,
|
||||
DrawElementsUBytePrimitiveType,
|
||||
DrawElementsUShortPrimitiveType,
|
||||
DrawElementsUIntPrimitiveType
|
||||
};
|
||||
|
||||
enum Mode
|
||||
@@ -69,8 +70,9 @@ class SG_EXPORT DrawArrays : public Primitive
|
||||
public:
|
||||
|
||||
DrawArrays(GLenum mode=0):
|
||||
Primitive(DrawArraysPrimitiveType,mode)
|
||||
{}
|
||||
Primitive(DrawArraysPrimitiveType,mode),
|
||||
_first(0),
|
||||
_count(0) {}
|
||||
|
||||
DrawArrays(GLenum mode, GLint first, GLsizei count):
|
||||
Primitive(DrawArraysPrimitiveType,mode),
|
||||
@@ -112,36 +114,85 @@ class SG_EXPORT DrawArrays : public Primitive
|
||||
GLsizei _count;
|
||||
};
|
||||
|
||||
typedef std::vector<GLubyte> UByteVector;
|
||||
class SG_EXPORT UByteDrawElements : public Primitive, public UByteVector
|
||||
typedef std::vector<GLsizei> VectorSizei;
|
||||
class SG_EXPORT DrawArrayLengths : public Primitive, public VectorSizei
|
||||
{
|
||||
public:
|
||||
|
||||
UByteDrawElements(GLenum mode=0):
|
||||
Primitive(UByteDrawElementsPrimitiveType,mode) {}
|
||||
DrawArrayLengths(GLenum mode=0):
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
_first(0) {}
|
||||
|
||||
UByteDrawElements(const UByteDrawElements& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
UByteVector(array) {}
|
||||
DrawArrayLengths(const DrawArrayLengths& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(dal,copyop),
|
||||
VectorSizei(dal),
|
||||
_first(dal._first) {}
|
||||
|
||||
UByteDrawElements(GLenum mode,unsigned int no,unsigned char* ptr) :
|
||||
Primitive(UByteDrawElementsPrimitiveType,mode),
|
||||
UByteVector(ptr,ptr+no) {}
|
||||
DrawArrayLengths(GLenum mode, GLint first, unsigned int no, GLsizei* ptr) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(ptr,ptr+no),
|
||||
_first(first) {}
|
||||
|
||||
UByteDrawElements(GLenum mode,unsigned int no) :
|
||||
Primitive(UByteDrawElementsPrimitiveType,mode),
|
||||
UByteVector(no) {}
|
||||
DrawArrayLengths(GLenum mode,GLint first, unsigned int no) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(no),
|
||||
_first(first) {}
|
||||
|
||||
template <class InputIterator>
|
||||
UByteDrawElements(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(UByteDrawElementsPrimitiveType,mode),
|
||||
UByteVector(first,last) {}
|
||||
DrawArrayLengths(GLenum mode, GLint first, InputIterator firstItr,InputIterator lastItr) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(firstItr,lastItr),
|
||||
_first(first) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew UByteDrawElements(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew UByteDrawElements(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const UByteDrawElements*>(obj)!=NULL; }
|
||||
virtual Object* cloneType() const { return osgNew DrawArrayLengths(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew DrawArrayLengths(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrayLengths*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "UByteDrawElements"; }
|
||||
virtual const char* className() const { return "DrawArrayLengths"; }
|
||||
|
||||
|
||||
void setFirst(GLint first) { _first = first; }
|
||||
GLint getFirst() const { return _first; }
|
||||
|
||||
virtual void draw() const;
|
||||
|
||||
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
|
||||
|
||||
protected:
|
||||
|
||||
GLint _first;
|
||||
};
|
||||
|
||||
typedef std::vector<GLubyte> VectorUByte;
|
||||
class SG_EXPORT DrawElementsUByte : public Primitive, public VectorUByte
|
||||
{
|
||||
public:
|
||||
|
||||
DrawElementsUByte(GLenum mode=0):
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode) {}
|
||||
|
||||
DrawElementsUByte(const DrawElementsUByte& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
VectorUByte(array) {}
|
||||
|
||||
DrawElementsUByte(GLenum mode,unsigned int no,unsigned char* ptr) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(ptr,ptr+no) {}
|
||||
|
||||
DrawElementsUByte(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
DrawElementsUByte(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUByte(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew DrawElementsUByte(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUByte*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "DrawElementsUByte"; }
|
||||
|
||||
virtual void draw() const ;
|
||||
|
||||
@@ -149,72 +200,72 @@ class SG_EXPORT UByteDrawElements : public Primitive, public UByteVector
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<GLushort> UShortVector;
|
||||
class SG_EXPORT UShortDrawElements : public Primitive, public UShortVector
|
||||
typedef std::vector<GLushort> VectorUShort;
|
||||
class SG_EXPORT DrawElementsUShort : public Primitive, public VectorUShort
|
||||
{
|
||||
public:
|
||||
|
||||
UShortDrawElements(GLenum mode=0):
|
||||
Primitive(UShortDrawElementsPrimitiveType,mode) {}
|
||||
DrawElementsUShort(GLenum mode=0):
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode) {}
|
||||
|
||||
UShortDrawElements(const UShortDrawElements& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElementsUShort(const DrawElementsUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
UShortVector(array) {}
|
||||
VectorUShort(array) {}
|
||||
|
||||
UShortDrawElements(GLenum mode,unsigned int no,unsigned short* ptr) :
|
||||
Primitive(UShortDrawElementsPrimitiveType,mode),
|
||||
UShortVector(ptr,ptr+no) {}
|
||||
DrawElementsUShort(GLenum mode,unsigned int no,unsigned short* ptr) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(ptr,ptr+no) {}
|
||||
|
||||
UShortDrawElements(GLenum mode,unsigned int no) :
|
||||
Primitive(UShortDrawElementsPrimitiveType,mode),
|
||||
UShortVector(no) {}
|
||||
DrawElementsUShort(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
UShortDrawElements(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(UShortDrawElementsPrimitiveType,mode),
|
||||
UShortVector(first,last) {}
|
||||
DrawElementsUShort(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew UShortDrawElements(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew UShortDrawElements(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const UShortDrawElements*>(obj)!=NULL; }
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUShort(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew DrawElementsUShort(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUShort*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "UShortDrawElements"; }
|
||||
virtual const char* className() const { return "DrawElementsUShort"; }
|
||||
|
||||
virtual void draw() const;
|
||||
|
||||
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
|
||||
};
|
||||
|
||||
typedef std::vector<GLuint> UIntVector;
|
||||
class SG_EXPORT UIntDrawElements : public Primitive, public UIntVector
|
||||
typedef std::vector<GLuint> VectorUInt;
|
||||
class SG_EXPORT DrawElementsUInt : public Primitive, public VectorUInt
|
||||
{
|
||||
public:
|
||||
|
||||
UIntDrawElements(GLenum mode=0):
|
||||
Primitive(UIntDrawElementsPrimitiveType,mode) {}
|
||||
DrawElementsUInt(GLenum mode=0):
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode) {}
|
||||
|
||||
UIntDrawElements(const UIntDrawElements& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElementsUInt(const DrawElementsUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
UIntVector(array) {}
|
||||
VectorUInt(array) {}
|
||||
|
||||
UIntDrawElements(GLenum mode,unsigned int no,unsigned int* ptr) :
|
||||
Primitive(UIntDrawElementsPrimitiveType,mode),
|
||||
UIntVector(ptr,ptr+no) {}
|
||||
DrawElementsUInt(GLenum mode,unsigned int no,unsigned int* ptr) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(ptr,ptr+no) {}
|
||||
|
||||
UIntDrawElements(GLenum mode,unsigned int no) :
|
||||
Primitive(UIntDrawElementsPrimitiveType,mode),
|
||||
UIntVector(no) {}
|
||||
DrawElementsUInt(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
UIntDrawElements(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(UIntDrawElementsPrimitiveType,mode),
|
||||
UIntVector(first,last) {}
|
||||
DrawElementsUInt(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew UIntDrawElements(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew UIntDrawElements(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const UIntDrawElements*>(obj)!=NULL; }
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUInt(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew DrawElementsUInt(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUInt*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "UIntDrawElements"; }
|
||||
virtual const char* className() const { return "DrawElementsUInt"; }
|
||||
|
||||
virtual void draw() const;
|
||||
|
||||
@@ -222,6 +273,11 @@ class SG_EXPORT UIntDrawElements : public Primitive, public UIntVector
|
||||
|
||||
};
|
||||
|
||||
// backwards compatibility with first incarnation of DrawElements nameing convention.
|
||||
typedef DrawElementsUByte UByteDrawElements;
|
||||
typedef DrawElementsUShort UShortDrawElements;
|
||||
typedef DrawElementsUInt UIntDrawElements;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -118,6 +118,15 @@ class SG_EXPORT State : public Referenced
|
||||
return applyMode(mode,enabled,ms);
|
||||
}
|
||||
|
||||
inline const bool applyTextureMode(unsigned int unit, const StateAttribute::GLMode mode,const bool enabled)
|
||||
{
|
||||
if (unit>=_textureModeMapList.size()) _textureModeMapList.resize(unit);
|
||||
ModeMap& modeMap = _textureModeMapList[unit];
|
||||
|
||||
ModeStack& ms = modeMap[mode];
|
||||
ms.changed = true;
|
||||
return applyMode(mode,enabled,ms);
|
||||
}
|
||||
|
||||
/** Apply an attribute if required. */
|
||||
inline const bool applyAttribute(const StateAttribute* attribute)
|
||||
@@ -127,6 +136,15 @@ class SG_EXPORT State : public Referenced
|
||||
return applyAttribute(attribute,as);
|
||||
}
|
||||
|
||||
inline const bool applyTextureAttribute(unsigned int unit, const StateAttribute* attribute)
|
||||
{
|
||||
if (unit>=_textureAttributeMapList.size()) _textureAttributeMapList.resize(unit);
|
||||
AttributeMap& attributeMap = _textureAttributeMapList[unit];
|
||||
|
||||
AttributeStack& as = attributeMap[attribute->getType()];
|
||||
as.changed = true;
|
||||
return applyAttribute(attribute,as);
|
||||
}
|
||||
|
||||
/** Mode has been set externally, update state to reflect this setting.*/
|
||||
void haveAppliedMode(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value);
|
||||
@@ -152,6 +170,219 @@ class SG_EXPORT State : public Referenced
|
||||
|
||||
/** Get the current specified attribute, return NULL is one has not yet been applied.*/
|
||||
const StateAttribute* getLastAppliedAttribute(const StateAttribute::Type type) const;
|
||||
|
||||
|
||||
|
||||
/** texture Mode has been set externally, update state to reflect this setting.*/
|
||||
void haveAppliedTextureMode(unsigned int unit, const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value);
|
||||
|
||||
/** texture Mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
void haveAppliedTextureMode(unsigned int unit, const StateAttribute::GLMode mode);
|
||||
|
||||
/** texture Attribute has been applied externally, update state to reflect this setting.*/
|
||||
void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute* attribute);
|
||||
|
||||
/** texture Attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-appplied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will the osg::State to
|
||||
* track the current state more accuratly and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute::Type type);
|
||||
|
||||
/** Get whether the current specified texture mode is enabled (true) or disabled (false).*/
|
||||
const bool getLastAppliedTextureMode(unsigned int unit, const StateAttribute::GLMode mode) const;
|
||||
|
||||
/** Get the current specified texture attribute, return NULL is one has not yet been applied.*/
|
||||
const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, const StateAttribute::Type type) const;
|
||||
|
||||
|
||||
|
||||
/** wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setVertexPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_vertexArray._enabled)
|
||||
{
|
||||
_vertexArray._enabled = true;
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
if (_vertexArray._pointer!=ptr)
|
||||
{
|
||||
_vertexArray._pointer=ptr;
|
||||
glVertexPointer( size, type, stride, ptr );
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper glDisableClientState(GL_VERTEX_ARRAY).
|
||||
* note, only updates values that change.*/
|
||||
inline void disableVertexPointer()
|
||||
{
|
||||
if (_vertexArray._enabled)
|
||||
{
|
||||
_vertexArray._enabled = false;
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setNormalPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
if (!_normalArray._enabled)
|
||||
{
|
||||
_normalArray._enabled = true;
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
}
|
||||
if (_normalArray._pointer!=ptr)
|
||||
{
|
||||
_normalArray._pointer=ptr;
|
||||
glNormalPointer( type, stride, ptr );
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_NORMAL_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableNormalPointer()
|
||||
{
|
||||
if (_normalArray._enabled)
|
||||
{
|
||||
_normalArray._enabled = false;
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setColorPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (!_colorArray._enabled)
|
||||
{
|
||||
_colorArray._enabled = true;
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
if (_colorArray._pointer!=ptr)
|
||||
{
|
||||
_colorArray._pointer=ptr;
|
||||
glColorPointer( size, type, stride, ptr );
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_COLOR_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableColorPointer()
|
||||
{
|
||||
if (_colorArray._enabled)
|
||||
{
|
||||
_colorArray._enabled = false;
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setIndexPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
if (!_indexArray._enabled)
|
||||
{
|
||||
_indexArray._enabled = true;
|
||||
glEnableClientState(GL_INDEX_ARRAY);
|
||||
}
|
||||
if (_indexArray._pointer!=ptr)
|
||||
{
|
||||
_indexArray._pointer=ptr;
|
||||
glIndexPointer( type, stride, ptr );
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_INDEX_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableIndexPointer()
|
||||
{
|
||||
//if (_indexArray._enabled)
|
||||
{
|
||||
_indexArray._enabled = false;
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setTexCoordPointer( unsigned int unit,
|
||||
GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
if (setClientActiveTextureUnit(unit))
|
||||
{
|
||||
if ( unit >= _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
|
||||
EnabledArrayPair& eap = _texCoordArrayList[unit];
|
||||
|
||||
//if (!eap._enabled)
|
||||
{
|
||||
eap._enabled = true;
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
if (eap._pointer!=ptr)
|
||||
{
|
||||
glTexCoordPointer( size, type, stride, ptr );
|
||||
eap._pointer = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableTexCoordPointer( unsigned int unit )
|
||||
{
|
||||
if (setClientActiveTextureUnit(unit))
|
||||
{
|
||||
if ( unit > _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
|
||||
EnabledArrayPair& eap = _texCoordArrayList[unit];
|
||||
|
||||
if (eap._enabled)
|
||||
{
|
||||
eap._enabled = false;
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** set the current tex coord array texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
inline bool setClientActiveTextureUnit( unsigned int unit )
|
||||
{
|
||||
return unit==0;
|
||||
// will need to check for extensions etc.
|
||||
// if (unit!=_currentClientActiveTextureUnit)
|
||||
// {
|
||||
// glClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
|
||||
// _currentClientActiveTextureUnit = unit;
|
||||
// }
|
||||
// return true;
|
||||
}
|
||||
|
||||
|
||||
/** set the current texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
inline bool setActiveTextureUnit( unsigned int unit )
|
||||
{
|
||||
return unit==0;
|
||||
//
|
||||
// if (unit!=_currentActiveTextureUnit)
|
||||
// {
|
||||
// glActiveTextureARB(GL_TEXTURE0_ARB+unit);
|
||||
// _currentActiveTextureUnit = unit;
|
||||
// }
|
||||
// return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Set the current OpenGL context uniqueID.
|
||||
@@ -275,13 +506,42 @@ class SG_EXPORT State : public Referenced
|
||||
}
|
||||
|
||||
typedef std::map<StateAttribute::GLMode,ModeStack> ModeMap;
|
||||
typedef std::vector<ModeMap> TextureModeMapList;
|
||||
|
||||
typedef std::map<StateAttribute::Type,AttributeStack> AttributeMap;
|
||||
typedef std::vector<AttributeMap> TextureAttributeMapList;
|
||||
|
||||
typedef std::vector<ref_ptr<const StateSet> > StateSetStack;
|
||||
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
||||
|
||||
ModeMap _modeMap;
|
||||
AttributeMap _attributeMap;
|
||||
StateSetStack _drawStateStack;
|
||||
ModeMap _modeMap;
|
||||
AttributeMap _attributeMap;
|
||||
|
||||
TextureModeMapList _textureModeMapList;
|
||||
TextureAttributeMapList _textureAttributeMapList;
|
||||
|
||||
StateSetStack _drawStateStack;
|
||||
|
||||
struct EnabledArrayPair
|
||||
{
|
||||
EnabledArrayPair():_enabled(false),_pointer(0) {}
|
||||
EnabledArrayPair(const EnabledArrayPair& eap):_enabled(eap._enabled),_pointer(eap._pointer) {}
|
||||
EnabledArrayPair& operator = (const EnabledArrayPair& eap) { _enabled=eap._enabled; _pointer=eap._pointer; return *this; }
|
||||
|
||||
bool _enabled;
|
||||
const GLvoid* _pointer;
|
||||
};
|
||||
|
||||
typedef std::vector<EnabledArrayPair> EnabledTexCoordArrayList;
|
||||
|
||||
EnabledArrayPair _vertexArray;
|
||||
EnabledArrayPair _colorArray;
|
||||
EnabledArrayPair _indexArray;
|
||||
EnabledArrayPair _normalArray;
|
||||
EnabledTexCoordArrayList _texCoordArrayList;
|
||||
|
||||
unsigned int _currentActiveTextureUnit;
|
||||
unsigned int _currentClientActiveTextureUnit;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -101,10 +101,6 @@ class SG_EXPORT StateAttribute : public Object
|
||||
enum Types
|
||||
{
|
||||
TEXTURE,
|
||||
TEXTURE_0 =TEXTURE,
|
||||
TEXTURE_1,
|
||||
TEXTURE_2,
|
||||
TEXTURE_3,
|
||||
|
||||
POLYGONMODE,
|
||||
POLYGONOFFSET,
|
||||
|
||||
@@ -75,6 +75,7 @@ class SG_EXPORT StateSet : public Object
|
||||
inline const ModeList& getModeList() const { return _modeList; }
|
||||
|
||||
|
||||
|
||||
/** simple pairing between an attribute and its override flag.*/
|
||||
typedef std::pair<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> RefAttributePair;
|
||||
/** a container to map StateAttribyte::Types to their respective RefAttributePair.*/
|
||||
@@ -106,6 +107,58 @@ class SG_EXPORT StateSet : public Object
|
||||
/** return the const list of all StateAttributes contained in this const StateSet.*/
|
||||
inline const AttributeList& getAttributeList() const { return _attributeList; }
|
||||
|
||||
|
||||
|
||||
typedef std::vector<ModeList> TextureModeList;
|
||||
|
||||
/** set this StateSet to contain specified GLMode and value.*/
|
||||
void setTextureMode(unsigned int unit,const StateAttribute::GLMode mode, const StateAttribute::GLModeValue value);
|
||||
/** set this StateSet to inherit specified GLMode type from parents.
|
||||
* has the effect of deleting any GlMode of specified type from StateSet.*/
|
||||
void setTextureModeToInherit(unsigned int unit,const StateAttribute::GLMode mode);
|
||||
|
||||
/** get specified GLModeValue for specified GLMode.
|
||||
* returns INHERIT if no GLModeValue is contained within StateSet.*/
|
||||
const StateAttribute::GLModeValue getTextureMode(unsigned int unit,const StateAttribute::GLMode mode) const;
|
||||
|
||||
/** return the list of all Texture related GLModes contained in this StateSet.*/
|
||||
inline TextureModeList& getTextureModeList() { return _textureModeList; }
|
||||
|
||||
/** return the const list of all Texture related GLModes contained in this const StateSet.*/
|
||||
inline const TextureModeList& getTextureModeList() const { return _textureModeList; }
|
||||
|
||||
|
||||
typedef std::vector<AttributeList> TextureAttributeList;
|
||||
|
||||
/** set this StateSet to contain specified attribute and override flag.*/
|
||||
void setTextureAttribute(unsigned int unit,StateAttribute *attribute, const StateAttribute::OverrideValue value=StateAttribute::OFF);
|
||||
/** set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/
|
||||
void setTextureAttributeAndModes(unsigned int unit,StateAttribute *attribute, const StateAttribute::GLModeValue value=StateAttribute::ON);
|
||||
/** set this StateSet to inherit specified attribute type from parents.
|
||||
* has the effect of deleting any state attributes of specified type from StateSet.*/
|
||||
void setTextureAttributeToInherit(unsigned int unit,const StateAttribute::Type type);
|
||||
|
||||
/** get specified Texture related StateAttribute for specified type.
|
||||
* returns NULL if no type is contained within StateSet.*/
|
||||
StateAttribute* getTextureAttribute(unsigned int unit,const StateAttribute::Type type);
|
||||
|
||||
/** get specified Texture related const StateAttribute for specified type.
|
||||
* returns NULL if no type is contained within const StateSet.*/
|
||||
const StateAttribute* getTextureAttribute(unsigned int unit,const StateAttribute::Type type) const;
|
||||
|
||||
/** get specified Texture related RefAttributePair for specified type.
|
||||
* returns NULL if no type is contained within StateSet.*/
|
||||
const RefAttributePair* getTextureAttributePair(unsigned int unit,const StateAttribute::Type type) const;
|
||||
|
||||
/** return the list of all Texture related StateAttributes contained in this StateSet.*/
|
||||
inline TextureAttributeList& getTextureAttributeList() { return _textureAttributeList; }
|
||||
|
||||
/** return the const list of all Texture related StateAttributes contained in this const StateSet.*/
|
||||
inline const TextureAttributeList& getTextureAttributeList() const { return _textureAttributeList; }
|
||||
|
||||
|
||||
|
||||
|
||||
enum RenderingHint
|
||||
{
|
||||
DEFAULT_BIN = 0,
|
||||
@@ -159,16 +212,30 @@ class SG_EXPORT StateSet : public Object
|
||||
virtual ~StateSet();
|
||||
|
||||
StateSet& operator = (const StateSet&) { return *this; }
|
||||
|
||||
|
||||
ModeList _modeList;
|
||||
AttributeList _attributeList;
|
||||
|
||||
int _renderingHint;
|
||||
ModeList _modeList;
|
||||
AttributeList _attributeList;
|
||||
|
||||
RenderBinMode _binMode;
|
||||
int _binNum;
|
||||
std::string _binName;
|
||||
TextureModeList _textureModeList;
|
||||
TextureAttributeList _textureAttributeList;
|
||||
|
||||
inline ModeList& getOrCreateTextureModeList(unsigned int unit)
|
||||
{
|
||||
if (unit>=_textureModeList.size()) _textureModeList.resize(unit+1);
|
||||
return _textureModeList[unit];
|
||||
}
|
||||
|
||||
inline AttributeList& getOrCreateTextureAttributeList(unsigned int unit)
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) _textureAttributeList.resize(unit+1);
|
||||
return _textureAttributeList[unit];
|
||||
}
|
||||
|
||||
int _renderingHint;
|
||||
|
||||
RenderBinMode _binMode;
|
||||
int _binNum;
|
||||
std::string _binName;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
_modifiedTag(),
|
||||
_image(copyop(text._image.get())),
|
||||
_target(text._target),
|
||||
_textureUnit(text._textureUnit),
|
||||
_wrap_s(text._wrap_s),
|
||||
_wrap_t(text._wrap_t),
|
||||
_wrap_r(text._wrap_r),
|
||||
@@ -102,7 +101,7 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
_subloadWidth(text._subloadWidth),
|
||||
_subloadHeight(text._subloadHeight) {}
|
||||
|
||||
META_StateAttribute(osg, Texture,(Type)(TEXTURE_0+_textureUnit));
|
||||
META_StateAttribute(osg, Texture,TEXTURE);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& rhs) const;
|
||||
@@ -136,17 +135,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
*/
|
||||
void copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height );
|
||||
|
||||
/** Set the texture unit.
|
||||
* Valid values are 0,1,2,3.
|
||||
* Default value of texture unit is 0.
|
||||
* note, multi-texturing not fully implemented yet... April 2001.
|
||||
*/
|
||||
inline void setTextureUnit(const unsigned int textureUnit) { _textureUnit = textureUnit; }
|
||||
|
||||
/** get the texture unit.*/
|
||||
inline const unsigned int getTextureUnit() const { return _textureUnit; }
|
||||
|
||||
|
||||
enum WrapParameter {
|
||||
WRAP_S,
|
||||
WRAP_T,
|
||||
@@ -342,8 +330,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
|
||||
GLenum _target; // defaults to GL_TEXTURE_2D
|
||||
|
||||
unsigned int _textureUnit;
|
||||
|
||||
WrapMode _wrap_s;
|
||||
WrapMode _wrap_t;
|
||||
WrapMode _wrap_r;
|
||||
|
||||
@@ -27,7 +27,7 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Texture(cm,copyop) {}
|
||||
|
||||
META_StateAttribute(osg, TextureCubeMap,(Type)(TEXTURE_0+_textureUnit));
|
||||
META_StateAttribute(osg, TextureCubeMap,TEXTURE);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& rhs) const;
|
||||
|
||||
@@ -1117,23 +1117,42 @@ Geometry* GeoSet::convertToGeometry()
|
||||
return 0;
|
||||
}
|
||||
|
||||
for( int i = 0; i < _numprims; i++ )
|
||||
if( _cindex.valid() )
|
||||
{
|
||||
if( _cindex.valid() )
|
||||
|
||||
for( int i = 0; i < _numprims; i++ )
|
||||
{
|
||||
UShortDrawElements* n = new UShortDrawElements;
|
||||
geom->addPrimitive(n);
|
||||
|
||||
|
||||
if (_cindex._is_ushort)
|
||||
geom->addPrimitive(osgNew UShortDrawElements( (GLenum)_oglprimtype, _primLengths[i],&_cindex._ptr._ushort[index] ));
|
||||
else
|
||||
geom->addPrimitive(osgNew UIntDrawElements( (GLenum)_oglprimtype, _primLengths[i], &_cindex._ptr._uint[index] ));
|
||||
|
||||
index += _primLengths[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_numprims==1)
|
||||
{
|
||||
DrawArrays* da = new DrawArrays(_oglprimtype,0,_primLengths[0]);
|
||||
geom->addPrimitive(da);
|
||||
}
|
||||
else
|
||||
geom->addPrimitive(osgNew DrawArrays( (GLenum)_oglprimtype, index, _primLengths[i] ));
|
||||
{
|
||||
DrawArrayLengths* dal = new DrawArrayLengths(_oglprimtype,0,_numprims);
|
||||
geom->addPrimitive(dal);
|
||||
for( int i = 0; i < _numprims; i++ )
|
||||
{
|
||||
(*dal)[i] = _primLengths[i];
|
||||
index += _primLengths[i];
|
||||
}
|
||||
}
|
||||
|
||||
index += _primLengths[i];
|
||||
}
|
||||
|
||||
}
|
||||
else // POINTS, LINES, TRIANGLES, QUADS
|
||||
{
|
||||
@@ -1284,10 +1303,12 @@ Geometry* GeoSet::convertToGeometry()
|
||||
|
||||
index += _primLengths[i];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// POINTS, LINES, TRIANGLES, QUADS
|
||||
|
||||
Vec3Array* coords = osgNew Vec3Array;
|
||||
Vec3Array* normals = 0;
|
||||
|
||||
@@ -40,28 +40,30 @@ Array* Geometry::getTexCoordArray(unsigned int unit)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void Geometry::drawImmediateMode(State& /*state*/)
|
||||
void Geometry::drawImmediateMode(State& state)
|
||||
{
|
||||
if (!_vertexArray.valid()) return;
|
||||
|
||||
// set up the vertex arrays.
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glVertexPointer(3,GL_FLOAT,0,_vertexArray->dataPointer());
|
||||
// glEnableClientState( GL_VERTEX_ARRAY );
|
||||
// glVertexPointer(3,GL_FLOAT,0,_vertexArray->dataPointer());
|
||||
|
||||
state.setVertexPointer(3,GL_FLOAT,0,_vertexArray->dataPointer());
|
||||
|
||||
// set up texture coordinates.
|
||||
for(unsigned int i=0;i<_texCoordList.size();++i)
|
||||
{
|
||||
Array* array = _texCoordList[i].get();
|
||||
//glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
|
||||
if (array)
|
||||
{
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glTexCoordPointer(array->dataSize(),array->dataType(),0,array->dataPointer());
|
||||
// glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
// glTexCoordPointer(array->dataSize(),array->dataType(),0,array->dataPointer());
|
||||
state.setTexCoordPointer(i,array->dataSize(),array->dataType(),0,array->dataPointer());
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
// glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
state.disableTexCoordPointer(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,18 +75,22 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
switch (_normalBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
glDisableClientState( GL_NORMAL_ARRAY );
|
||||
// glDisableClientState( GL_NORMAL_ARRAY );
|
||||
state.disableNormalPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
glDisableClientState( GL_NORMAL_ARRAY );
|
||||
// glDisableClientState( GL_NORMAL_ARRAY );
|
||||
state.disableNormalPointer();
|
||||
if (normalPointer) glNormal3fv(reinterpret_cast<const GLfloat*>(normalPointer));
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
glDisableClientState( GL_NORMAL_ARRAY );
|
||||
// glDisableClientState( GL_NORMAL_ARRAY );
|
||||
state.disableNormalPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
glEnableClientState( GL_NORMAL_ARRAY );
|
||||
if (normalPointer) glNormalPointer(GL_FLOAT,0,normalPointer);
|
||||
// glEnableClientState( GL_NORMAL_ARRAY );
|
||||
// if (normalPointer) glNormalPointer(GL_FLOAT,0,normalPointer);
|
||||
if (normalPointer) state.setNormalPointer(GL_FLOAT,0,normalPointer);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -124,10 +130,12 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
switch (_colorBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
state.disableColorPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
state.disableColorPointer();
|
||||
if (colorPointer)
|
||||
{
|
||||
switch(colorType)
|
||||
@@ -145,11 +153,13 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
}
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
state.disableColorPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
if (colorPointer) glColorPointer(_colorArray->dataSize(),_colorArray->dataType(),0,colorPointer);
|
||||
// glEnableClientState( GL_COLOR_ARRAY );
|
||||
// if (colorPointer) glColorPointer(_colorArray->dataSize(),_colorArray->dataType(),0,colorPointer);
|
||||
if (colorPointer) state.setColorPointer(_colorArray->dataSize(),_colorArray->dataType(),0,colorPointer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,36 +12,61 @@ void DrawArrays::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
functor.drawArrays(_mode,_first,_count);
|
||||
}
|
||||
|
||||
void DrawArrayLengths::draw() const
|
||||
{
|
||||
GLint first = _first;
|
||||
for(VectorSizei::const_iterator itr=begin();
|
||||
itr!=end();
|
||||
++itr)
|
||||
{
|
||||
glDrawArrays(_mode,first,*itr);
|
||||
first += *itr;
|
||||
}
|
||||
}
|
||||
|
||||
void UByteDrawElements::draw() const
|
||||
void DrawArrayLengths::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
GLint first = _first;
|
||||
for(VectorSizei::iterator itr=begin();
|
||||
itr!=end();
|
||||
++itr)
|
||||
{
|
||||
functor.drawArrays(_mode,first,*itr);
|
||||
first += *itr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawElementsUByte::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_BYTE,&front());
|
||||
}
|
||||
|
||||
void UByteDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
void DrawElementsUByte::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
|
||||
void UShortDrawElements::draw() const
|
||||
void DrawElementsUShort::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_SHORT,&front());
|
||||
}
|
||||
|
||||
void UShortDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
void DrawElementsUShort::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UIntDrawElements::draw() const
|
||||
void DrawElementsUInt::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_INT,&front());
|
||||
}
|
||||
|
||||
void UIntDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
void DrawElementsUInt::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,30 @@ StateSet::StateSet(const StateSet& rhs,const CopyOp& copyop):Object(rhs,copyop)
|
||||
if (attr) _attributeList[type]=RefAttributePair(attr,rap.second);
|
||||
}
|
||||
|
||||
// copy texture related modes.
|
||||
_textureModeList = rhs._textureModeList;
|
||||
|
||||
// set up the size of the texture attribute list.
|
||||
_textureAttributeList.resize(rhs._textureAttributeList.size());
|
||||
|
||||
// copy the contents across.
|
||||
for(unsigned int i=0;i<rhs._textureAttributeList.size();++i)
|
||||
{
|
||||
|
||||
AttributeList& lhs_attributeList = _textureAttributeList[i];
|
||||
const AttributeList& rhs_attributeList = rhs._textureAttributeList[i];
|
||||
for(AttributeList::const_iterator itr=rhs_attributeList.begin();
|
||||
itr!=rhs_attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
StateAttribute::Type type = itr->first;
|
||||
const RefAttributePair& rap = itr->second;
|
||||
StateAttribute* attr = copyop(rap.first.get());
|
||||
if (attr) lhs_attributeList[type]=RefAttributePair(attr,rap.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_renderingHint = rhs._renderingHint;
|
||||
|
||||
_binMode = rhs._binMode;
|
||||
@@ -54,6 +78,61 @@ StateSet::~StateSet()
|
||||
int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const
|
||||
{
|
||||
|
||||
if (_textureAttributeList.size()<rhs._textureAttributeList.size()) return -1;
|
||||
if (_textureAttributeList.size()>rhs._textureAttributeList.size()) return 1;
|
||||
|
||||
for(unsigned int ai=0;ai<_textureAttributeList.size();++ai)
|
||||
{
|
||||
const AttributeList& rhs_attributeList = _textureAttributeList[ai];
|
||||
const AttributeList& lhs_attributeList = rhs._textureAttributeList[ai];
|
||||
if (compareAttributeContents)
|
||||
{
|
||||
// now check to see how the attributes compare.
|
||||
AttributeList::const_iterator lhs_attr_itr = lhs_attributeList.begin();
|
||||
AttributeList::const_iterator rhs_attr_itr = rhs_attributeList.begin();
|
||||
while (lhs_attr_itr!=lhs_attributeList.end() && rhs_attr_itr!=rhs_attributeList.end())
|
||||
{
|
||||
if (lhs_attr_itr->first<rhs_attr_itr->first) return -1;
|
||||
else if (rhs_attr_itr->first<lhs_attr_itr->first) return 1;
|
||||
if (*(lhs_attr_itr->second.first)<*(rhs_attr_itr->second.first)) return -1;
|
||||
else if (*(rhs_attr_itr->second.first)<*(lhs_attr_itr->second.first)) return 1;
|
||||
if (lhs_attr_itr->second.second<rhs_attr_itr->second.second) return -1;
|
||||
else if (rhs_attr_itr->second.second<lhs_attr_itr->second.second) return 1;
|
||||
++lhs_attr_itr;
|
||||
++rhs_attr_itr;
|
||||
}
|
||||
if (lhs_attr_itr==lhs_attributeList.end())
|
||||
{
|
||||
if (rhs_attr_itr!=rhs_attributeList.end()) return -1;
|
||||
}
|
||||
else if (rhs_attr_itr == rhs_attributeList.end()) return 1;
|
||||
}
|
||||
else // just compare pointers.
|
||||
{
|
||||
// now check to see how the attributes compare.
|
||||
AttributeList::const_iterator lhs_attr_itr = lhs_attributeList.begin();
|
||||
AttributeList::const_iterator rhs_attr_itr = rhs_attributeList.begin();
|
||||
while (lhs_attr_itr!=lhs_attributeList.end() && rhs_attr_itr!=rhs_attributeList.end())
|
||||
{
|
||||
if (lhs_attr_itr->first<rhs_attr_itr->first) return -1;
|
||||
else if (rhs_attr_itr->first<lhs_attr_itr->first) return 1;
|
||||
if (lhs_attr_itr->second.first<rhs_attr_itr->second.first) return -1;
|
||||
else if (rhs_attr_itr->second.first<lhs_attr_itr->second.first) return 1;
|
||||
if (lhs_attr_itr->second.second<rhs_attr_itr->second.second) return -1;
|
||||
else if (rhs_attr_itr->second.second<lhs_attr_itr->second.second) return 1;
|
||||
++lhs_attr_itr;
|
||||
++rhs_attr_itr;
|
||||
}
|
||||
if (lhs_attr_itr==lhs_attributeList.end())
|
||||
{
|
||||
if (rhs_attr_itr!=rhs_attributeList.end()) return -1;
|
||||
}
|
||||
else if (rhs_attr_itr == rhs_attributeList.end()) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now check the rest of the non texture attributes
|
||||
if (compareAttributeContents)
|
||||
{
|
||||
// now check to see how the attributes compare.
|
||||
@@ -101,8 +180,36 @@ int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const
|
||||
|
||||
// we've got here so attributes must be equal...
|
||||
|
||||
// check to see how the modes compare.
|
||||
|
||||
if (_textureModeList.size()<rhs._textureModeList.size()) return -1;
|
||||
if (_textureModeList.size()>rhs._textureModeList.size()) return 1;
|
||||
|
||||
// check to see how the modes compare.
|
||||
// first check the rest of the texture modes
|
||||
for(unsigned int ti=0;ti<_textureModeList.size();++ti)
|
||||
{
|
||||
const ModeList& lhs_modeList = _textureModeList[ti];
|
||||
const ModeList& rhs_modeList = rhs._textureModeList[ti];
|
||||
|
||||
ModeList::const_iterator lhs_mode_itr = lhs_modeList.begin();
|
||||
ModeList::const_iterator rhs_mode_itr = rhs_modeList.begin();
|
||||
while (lhs_mode_itr!=lhs_modeList.end() && rhs_mode_itr!=rhs_modeList.end())
|
||||
{
|
||||
if (lhs_mode_itr->first<rhs_mode_itr->first) return -1;
|
||||
else if (rhs_mode_itr->first<lhs_mode_itr->first) return 1;
|
||||
if (lhs_mode_itr->second<rhs_mode_itr->second) return -1;
|
||||
else if (rhs_mode_itr->second<lhs_mode_itr->second) return 1;
|
||||
++lhs_mode_itr;
|
||||
++rhs_mode_itr;
|
||||
}
|
||||
if (lhs_mode_itr==lhs_modeList.end())
|
||||
{
|
||||
if (rhs_mode_itr!=rhs_modeList.end()) return -1;
|
||||
}
|
||||
else if (rhs_mode_itr == rhs_modeList.end()) return 1;
|
||||
}
|
||||
|
||||
// check non texture modes.
|
||||
ModeList::const_iterator lhs_mode_itr = _modeList.begin();
|
||||
ModeList::const_iterator rhs_mode_itr = rhs._modeList.begin();
|
||||
while (lhs_mode_itr!=_modeList.end() && rhs_mode_itr!=rhs._modeList.end())
|
||||
@@ -172,6 +279,10 @@ void StateSet::setAllToInherit()
|
||||
|
||||
_modeList.clear();
|
||||
_attributeList.clear();
|
||||
|
||||
_textureModeList.clear();
|
||||
_textureAttributeList.clear();
|
||||
|
||||
}
|
||||
|
||||
void StateSet::merge(const StateSet& rhs)
|
||||
@@ -222,6 +333,66 @@ void StateSet::merge(const StateSet& rhs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_textureModeList.size()<rhs._textureModeList.size()) _textureModeList.resize(rhs._textureModeList.size());
|
||||
for(unsigned int mi=0;mi<rhs._textureModeList.size();++mi)
|
||||
{
|
||||
ModeList& lhs_modeList = _textureModeList[mi];
|
||||
const ModeList& rhs_modeList = rhs._textureModeList[mi];
|
||||
// merge the modes of rhs into this,
|
||||
// this overrides rhs if OVERRIDE defined in this.
|
||||
for(ModeList::const_iterator rhs_mitr = rhs_modeList.begin();
|
||||
rhs_mitr != rhs_modeList.end();
|
||||
++rhs_mitr)
|
||||
{
|
||||
ModeList::iterator lhs_mitr = lhs_modeList.find(rhs_mitr->first);
|
||||
if (lhs_mitr!=lhs_modeList.end())
|
||||
{
|
||||
if (!(lhs_mitr->second & StateAttribute::OVERRIDE))
|
||||
{
|
||||
// override isn't on in rhs, so overrite it with incomming
|
||||
// value.
|
||||
lhs_mitr->second = rhs_mitr->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// entry doesn't exist so insert it.
|
||||
lhs_modeList.insert(*rhs_mitr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_textureAttributeList.size()<rhs._textureAttributeList.size()) _textureAttributeList.resize(rhs._textureAttributeList.size());
|
||||
for(unsigned int ai=0;ai<rhs._textureAttributeList.size();++ai)
|
||||
{
|
||||
AttributeList& lhs_attributeList = _textureAttributeList[ai];
|
||||
const AttributeList& rhs_attributeList = rhs._textureAttributeList[ai];
|
||||
|
||||
// merge the attributes of rhs into this,
|
||||
// this overrides rhs if OVERRIDE defined in this.
|
||||
for(AttributeList::const_iterator rhs_aitr = rhs_attributeList.begin();
|
||||
rhs_aitr != rhs_attributeList.end();
|
||||
++rhs_aitr)
|
||||
{
|
||||
AttributeList::iterator lhs_aitr = lhs_attributeList.find(rhs_aitr->first);
|
||||
if (lhs_aitr!=lhs_attributeList.end())
|
||||
{
|
||||
if (!(lhs_aitr->second.second & StateAttribute::OVERRIDE))
|
||||
{
|
||||
// override isn't on in rhs, so overrite it with incomming
|
||||
// value.
|
||||
lhs_aitr->second = rhs_aitr->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// entry doesn't exist so insert it.
|
||||
lhs_attributeList.insert(*rhs_aitr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// need to merge rendering hints
|
||||
// but will need to think how best to do this first
|
||||
// RO, Nov. 2001.
|
||||
@@ -316,6 +487,119 @@ const StateSet::RefAttributePair* StateSet::getAttributePair(const StateAttribut
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StateSet::setTextureMode(unsigned int unit,const StateAttribute::GLMode mode, const StateAttribute::GLModeValue value)
|
||||
{
|
||||
ModeList& modeList = getOrCreateTextureModeList(unit);
|
||||
if ((value&StateAttribute::INHERIT)) setTextureModeToInherit(unit,mode);
|
||||
else modeList[mode] = value;
|
||||
}
|
||||
|
||||
void StateSet::setTextureModeToInherit(unsigned int unit,const StateAttribute::GLMode mode)
|
||||
{
|
||||
if (unit>=_textureModeList.size()) return;
|
||||
ModeList& modeList = _textureModeList[unit];
|
||||
ModeList::iterator itr = modeList.find(mode);
|
||||
if (itr!=modeList.end())
|
||||
{
|
||||
modeList.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const StateAttribute::GLModeValue StateSet::getTextureMode(unsigned int unit,const StateAttribute::GLMode mode) const
|
||||
{
|
||||
if (unit>=_textureModeList.size()) return StateAttribute::INHERIT;
|
||||
|
||||
const ModeList& modeList = _textureModeList[unit];
|
||||
ModeList::const_iterator itr = modeList.find(mode);
|
||||
if (itr!=modeList.end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
else
|
||||
return StateAttribute::INHERIT;
|
||||
}
|
||||
|
||||
void StateSet::setTextureAttribute(unsigned int unit,StateAttribute *attribute, const StateAttribute::OverrideValue value=StateAttribute::OFF)
|
||||
{
|
||||
if (attribute)
|
||||
{
|
||||
AttributeList& attributeList = getOrCreateTextureAttributeList(unit);
|
||||
if ((value&StateAttribute::INHERIT)) setAttributeToInherit(attribute->getType());
|
||||
else attributeList[attribute->getType()] = RefAttributePair(attribute,value&StateAttribute::OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StateSet::setTextureAttributeAndModes(unsigned int unit,StateAttribute *attribute, const StateAttribute::GLModeValue value=StateAttribute::ON)
|
||||
{
|
||||
if (attribute)
|
||||
{
|
||||
AttributeList& attributeList = getOrCreateTextureAttributeList(unit);
|
||||
attributeList[attribute->getType()] = RefAttributePair(attribute,value&StateAttribute::OVERRIDE);
|
||||
attribute->setStateSetModes(*this,value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StateSet::setTextureAttributeToInherit(unsigned int unit,const StateAttribute::Type type)
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return;
|
||||
AttributeList& attributeList = _textureAttributeList[unit];
|
||||
AttributeList::iterator itr = attributeList.find(type);
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
itr->second.first->setStateSetModes(*this,StateAttribute::INHERIT);
|
||||
attributeList.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StateAttribute* StateSet::getTextureAttribute(unsigned int unit,const StateAttribute::Type type)
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
AttributeList& attributeList = _textureAttributeList[unit];
|
||||
AttributeList::iterator itr = attributeList.find(type);
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return itr->second.first.get();
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const StateAttribute* StateSet::getTextureAttribute(unsigned int unit,const StateAttribute::Type type) const
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
const AttributeList& attributeList = _textureAttributeList[unit];
|
||||
AttributeList::const_iterator itr = attributeList.find(type);
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return itr->second.first.get();
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const StateSet::RefAttributePair* StateSet::getTextureAttributePair(unsigned int unit,const StateAttribute::Type type) const
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
const AttributeList& attributeList = _textureAttributeList[unit];
|
||||
AttributeList::const_iterator itr = attributeList.find(type);
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return &(itr->second);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StateSet::compile(State& state) const
|
||||
{
|
||||
for(AttributeList::const_iterator itr = _attributeList.begin();
|
||||
@@ -324,6 +608,18 @@ void StateSet::compile(State& state) const
|
||||
{
|
||||
itr->second.first->compile(state);
|
||||
}
|
||||
|
||||
for(TextureAttributeList::const_iterator taitr=_textureAttributeList.begin();
|
||||
taitr!=_textureAttributeList.end();
|
||||
++taitr)
|
||||
{
|
||||
for(AttributeList::const_iterator itr = taitr->begin();
|
||||
itr!=taitr->end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.first->compile(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StateSet::setRenderingHint(const int hint)
|
||||
@@ -352,3 +648,9 @@ void StateSet::setRendingBinToInherit()
|
||||
_binNum = 0;
|
||||
_binName = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ Texture::Texture()
|
||||
|
||||
_target = GL_TEXTURE_2D;
|
||||
|
||||
_textureUnit = 0;
|
||||
|
||||
_wrap_s = CLAMP;
|
||||
_wrap_t = CLAMP;
|
||||
_wrap_r = CLAMP;
|
||||
@@ -83,7 +81,6 @@ int Texture::compare(const StateAttribute& sa) const
|
||||
}
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_textureUnit)
|
||||
COMPARE_StateAttribute_Parameter(_wrap_s)
|
||||
COMPARE_StateAttribute_Parameter(_wrap_t)
|
||||
COMPARE_StateAttribute_Parameter(_wrap_r)
|
||||
@@ -191,9 +188,6 @@ void Texture::apply(State& state) const
|
||||
// get the globj for the current contextID.
|
||||
GLuint& handle = getHandle(contextID);
|
||||
|
||||
// For multi-texturing will need something like...
|
||||
//glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB+_textureUnit));
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
if (_subloadMode == OFF)
|
||||
@@ -611,8 +605,6 @@ void Texture::copyTexImage2D(State& state, int x, int y, int width, int height )
|
||||
// RO July 2001.
|
||||
}
|
||||
|
||||
// For multi-texturing will need something like...
|
||||
// glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB+_textureUnit));
|
||||
|
||||
// remove any previously assigned images as these are nolonger valid.
|
||||
_image = NULL;
|
||||
@@ -650,6 +642,7 @@ void Texture::copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, i
|
||||
|
||||
if (handle)
|
||||
{
|
||||
|
||||
// we have a valid image
|
||||
glBindTexture( _target, handle );
|
||||
applyTexParameters(_target,state);
|
||||
|
||||
@@ -181,9 +181,6 @@ void TextureCubeMap::apply(State& state) const
|
||||
// get the globj for the current contextID.
|
||||
GLuint& handle = getHandle(contextID);
|
||||
|
||||
// For multi-texturing will need something like...
|
||||
// glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB+_textureUnit));
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
if (_subloadMode == OFF)
|
||||
|
||||
@@ -1319,7 +1319,7 @@ std::string DXWriter::BuildStateSetAttributes( MyStateSet &sset,
|
||||
}
|
||||
|
||||
// Texture
|
||||
if ( sset.HasAttribute( osg::StateAttribute::TEXTURE_0 ) ) {
|
||||
if ( sset.HasAttribute( osg::StateAttribute::TEXTURE ) ) {
|
||||
sprintf( buf, "attribute \"texture wrap s\" string \"%s\"\n",
|
||||
sset.wrap_s == GL_CLAMP ? "clamp" : "repeat" );
|
||||
str += buf;
|
||||
@@ -1631,7 +1631,7 @@ std::string DXWriter::WriteGeoSetField( const std::string &field_name,
|
||||
// If texturing is on, write the texture as a DX image field, and give
|
||||
// us back the name of field
|
||||
int has_uv = num_tcoords > 0 && tbinding == osg::GeoSet::BIND_PERVERTEX;
|
||||
int has_texture = sset.HasAttribute( osg::StateAttribute::TEXTURE_0 );
|
||||
int has_texture = sset.HasAttribute( osg::StateAttribute::TEXTURE );
|
||||
int has_texgen = sset.HasAttribute( osg::StateAttribute::TEXGEN );
|
||||
|
||||
std::string texture_name;
|
||||
@@ -2002,7 +2002,7 @@ void MyStateSet::Query( const osg::StateSet &sset )
|
||||
}
|
||||
|
||||
// TEXTURE / TEXTURE_0
|
||||
attr = sset.getAttribute( osg::StateAttribute::TEXTURE_0 );
|
||||
attr = sset.getAttribute( osg::StateAttribute::TEXTURE );
|
||||
if ( attr &&
|
||||
( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
|
||||
@@ -2011,7 +2011,7 @@ void MyStateSet::Query( const osg::StateSet &sset )
|
||||
// NOTE: If OSG failed to load the texture, we'll get a NULL right here
|
||||
image = texture.getImage();
|
||||
if ( image )
|
||||
AddAttribute( osg::StateAttribute::TEXTURE_0 );
|
||||
AddAttribute( osg::StateAttribute::TEXTURE );
|
||||
|
||||
// NOTE: DX limitations
|
||||
// Traditional DX doesn't support any texture control besides specifying
|
||||
|
||||
@@ -95,10 +95,6 @@ static void initOSGAttrNames()
|
||||
if (!first_time) return;
|
||||
|
||||
ADD_ATTR( osg::StateAttribute::TEXTURE , "TEXTURE" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXTURE_0 , "TEXTURE_0" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXTURE_1 , "TEXTURE_1" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXTURE_2 , "TEXTURE_2" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXTURE_3 , "TEXTURE_3" );
|
||||
ADD_ATTR( osg::StateAttribute::MATERIAL , "MATERIAL" );
|
||||
ADD_ATTR( osg::StateAttribute::ALPHAFUNC , "ALPHAFUNC" );
|
||||
ADD_ATTR( osg::StateAttribute::ANTIALIAS , "ANTIALIAS" );
|
||||
|
||||
@@ -517,7 +517,42 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
iteratorAdvanced = true;
|
||||
|
||||
}
|
||||
else if (fr.matchSequence("UByteDrawElements %w %i {"))
|
||||
else if (fr.matchSequence("DrawArrayLengths %w %i %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
GLenum mode;
|
||||
Geometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int first;
|
||||
fr[2].getInt(first);
|
||||
|
||||
int capacity;
|
||||
fr[3].getInt(capacity);
|
||||
|
||||
fr += 5;
|
||||
|
||||
DrawArrayLengths* prim = osgNew DrawArrayLengths;
|
||||
prim->setMode(mode);
|
||||
prim->setFirst(first);
|
||||
prim->reserve(capacity);
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int i;
|
||||
if (fr[0].getUInt(i))
|
||||
{
|
||||
prim->push_back(i);
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
++fr;
|
||||
|
||||
geom.addPrimitive(prim);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("DrawElementsUByte %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
@@ -529,7 +564,7 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
|
||||
fr += 4;
|
||||
|
||||
UByteDrawElements* prim = osgNew UByteDrawElements;
|
||||
DrawElementsUByte* prim = osgNew DrawElementsUByte;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
@@ -548,7 +583,7 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("UShortDrawElements %w %i {"))
|
||||
else if (fr.matchSequence("DrawElementsUShort %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
@@ -560,7 +595,7 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
|
||||
fr += 4;
|
||||
|
||||
UShortDrawElements* prim = osgNew UShortDrawElements;
|
||||
DrawElementsUShort* prim = osgNew DrawElementsUShort;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
@@ -579,7 +614,7 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("UIntDrawElements %w %i {"))
|
||||
else if (fr.matchSequence("DrawElementsUInt %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
@@ -591,7 +626,7 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
|
||||
fr += 4;
|
||||
|
||||
UIntDrawElements* prim = osgNew UIntDrawElements;
|
||||
DrawElementsUInt* prim = osgNew DrawElementsUInt;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
@@ -626,25 +661,33 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::UByteDrawElementsPrimitiveType):
|
||||
case(Primitive::DrawArrayLengthsPrimitiveType):
|
||||
{
|
||||
const UByteDrawElements& cprim = static_cast<const UByteDrawElements&>(prim);
|
||||
const DrawArrayLengths& cprim = static_cast<const DrawArrayLengths&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.size()<<std::endl;
|
||||
Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
const DrawElementsUByte& cprim = static_cast<const DrawElementsUByte&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::UShortDrawElementsPrimitiveType):
|
||||
case(Primitive::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
const UShortDrawElements& cprim = static_cast<const UShortDrawElements&>(prim);
|
||||
const DrawElementsUShort& cprim = static_cast<const DrawElementsUShort&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::UIntDrawElementsPrimitiveType):
|
||||
case(Primitive::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
const UIntDrawElements& cprim = static_cast<const UIntDrawElements&>(prim);
|
||||
const DrawElementsUInt& cprim = static_cast<const DrawElementsUInt&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_cullingMode = osg::CullStack::ENABLE_ALL_CULLING;
|
||||
_LODBias = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
_smallFeatureCullingPixelSize = 3.0f;
|
||||
|
||||
_lightingMode=HEADLIGHT;
|
||||
|
||||
|
||||
@@ -123,10 +123,10 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::UByteDrawElementsPrimitiveType):
|
||||
case(osg::Primitive::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
osg::UByteDrawElements* drawElements = static_cast<osg::UByteDrawElements*>(primitive);
|
||||
for(osg::UByteDrawElements::iterator indexItr=drawElements->begin();
|
||||
osg::DrawElementsUByte* drawElements = static_cast<osg::DrawElementsUByte*>(primitive);
|
||||
for(osg::DrawElementsUByte::iterator indexItr=drawElements->begin();
|
||||
indexItr!=drawElements->end();
|
||||
++indexItr)
|
||||
{
|
||||
@@ -134,10 +134,10 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::UShortDrawElementsPrimitiveType):
|
||||
case(osg::Primitive::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
osg::UShortDrawElements* drawElements = static_cast<osg::UShortDrawElements*>(primitive);
|
||||
for(osg::UShortDrawElements::iterator indexItr=drawElements->begin();
|
||||
osg::DrawElementsUShort* drawElements = static_cast<osg::DrawElementsUShort*>(primitive);
|
||||
for(osg::DrawElementsUShort::iterator indexItr=drawElements->begin();
|
||||
indexItr!=drawElements->end();
|
||||
++indexItr)
|
||||
{
|
||||
@@ -145,10 +145,10 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::UIntDrawElementsPrimitiveType):
|
||||
case(osg::Primitive::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
osg::UIntDrawElements* drawElements = static_cast<osg::UIntDrawElements*>(primitive);
|
||||
for(osg::UIntDrawElements::iterator indexItr=drawElements->begin();
|
||||
osg::DrawElementsUInt* drawElements = static_cast<osg::DrawElementsUInt*>(primitive);
|
||||
for(osg::DrawElementsUInt::iterator indexItr=drawElements->begin();
|
||||
indexItr!=drawElements->end();
|
||||
++indexItr)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
{
|
||||
Prim* prim = primItr->get();
|
||||
|
||||
osg::UShortDrawElements* elements = new osg::UShortDrawElements(prim->_mode);
|
||||
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(prim->_mode);
|
||||
for(Prim::VecList::iterator vitr=prim->_vertices.begin();
|
||||
vitr!=prim->_vertices.end();
|
||||
++vitr)
|
||||
|
||||
Reference in New Issue
Block a user