Converted the template DrawElements primitive class into three seperate
non templated classes - UByteDrawElements, UShortDrawElements, UIntDrawElements.
This commit is contained in:
@@ -4,7 +4,7 @@ using namespace osg;
|
||||
|
||||
static char* s_ArrayNames[] =
|
||||
{
|
||||
"AttributeArray", // 0
|
||||
"Array", // 0
|
||||
"ByteArray", // 1
|
||||
"ShortArray", // 2
|
||||
"IntArray", // 3
|
||||
@@ -20,11 +20,11 @@ static char* s_ArrayNames[] =
|
||||
"Vec4Array", // 11
|
||||
};
|
||||
|
||||
const char* AttributeArray::className() const
|
||||
const char* Array::className() const
|
||||
{
|
||||
if (_arrayType>=AttributeArrayType && _arrayType<=Vec4ArrayType)
|
||||
if (_arrayType>=ArrayType && _arrayType<=Vec4ArrayType)
|
||||
return s_ArrayNames[_arrayType];
|
||||
else
|
||||
return "UnkownAttributeArray";
|
||||
return "UnkownArray";
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Geometry::~Geometry()
|
||||
// no need to delete, all automatically handled by ref_ptr :-)
|
||||
}
|
||||
|
||||
void Geometry::setTexCoordArray(unsigned int unit,AttributeArray* array)
|
||||
void Geometry::setTexCoordArray(unsigned int unit,Array* array)
|
||||
{
|
||||
if (_texCoordList.size()<=unit)
|
||||
_texCoordList.resize(unit+1,0);
|
||||
@@ -34,7 +34,7 @@ void Geometry::setTexCoordArray(unsigned int unit,AttributeArray* array)
|
||||
dirtyDisplayList();
|
||||
}
|
||||
|
||||
AttributeArray* Geometry::getTexCoordArray(unsigned int unit)
|
||||
Array* Geometry::getTexCoordArray(unsigned int unit)
|
||||
{
|
||||
if (unit<_texCoordList.size()) return _texCoordList[unit].get();
|
||||
else return 0;
|
||||
@@ -52,7 +52,7 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
// set up texture coordinates.
|
||||
for(unsigned int i=0;i<_texCoordList.size();++i)
|
||||
{
|
||||
AttributeArray* array = _texCoordList[i].get();
|
||||
Array* array = _texCoordList[i].get();
|
||||
//glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
|
||||
if (array)
|
||||
{
|
||||
@@ -94,25 +94,25 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
// Vec3, Vec4 or UByte4 Arrays.
|
||||
const unsigned char* colorPointer = 0;
|
||||
unsigned int colorStride = 0;
|
||||
ArrayType colorType = AttributeArrayType;
|
||||
Array::Type colorType = Array::ArrayType;
|
||||
if (_colorArray.valid())
|
||||
{
|
||||
colorType = _colorArray->arrayType();
|
||||
colorType = _colorArray->getType();
|
||||
switch(colorType)
|
||||
{
|
||||
case(UByte4ArrayType):
|
||||
case(Array::UByte4ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->dataPointer());
|
||||
colorStride = 4;
|
||||
break;
|
||||
}
|
||||
case(Vec3ArrayType):
|
||||
case(Array::Vec3ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->dataPointer());
|
||||
colorStride = 12;
|
||||
break;
|
||||
}
|
||||
case(Vec4ArrayType):
|
||||
case(Array::Vec4ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->dataPointer());
|
||||
colorStride = 16;
|
||||
@@ -132,13 +132,13 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
{
|
||||
switch(colorType)
|
||||
{
|
||||
case(UByte4ArrayType):
|
||||
case(Array::UByte4ArrayType):
|
||||
glColor4ubv(reinterpret_cast<const GLubyte*>(colorPointer));
|
||||
break;
|
||||
case(Vec3ArrayType):
|
||||
case(Array::Vec3ArrayType):
|
||||
glColor3fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
case(Vec4ArrayType):
|
||||
case(Array::Vec4ArrayType):
|
||||
glColor4fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
}
|
||||
@@ -167,13 +167,13 @@ void Geometry::drawImmediateMode(State& /*state*/)
|
||||
{
|
||||
switch(colorType)
|
||||
{
|
||||
case(UByte4ArrayType):
|
||||
case(Array::UByte4ArrayType):
|
||||
glColor4ubv(reinterpret_cast<const GLubyte*>(colorPointer));
|
||||
break;
|
||||
case(Vec3ArrayType):
|
||||
case(Array::Vec3ArrayType):
|
||||
glColor3fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
case(Vec4ArrayType):
|
||||
case(Array::Vec4ArrayType):
|
||||
glColor4fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,20 +2,46 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
static char* s_PrimitiveNames[] =
|
||||
void DrawArrays::draw() const
|
||||
{
|
||||
"Primitive", // 0
|
||||
"DrawArrays", // 1
|
||||
"UByteDrawElements", // 2
|
||||
"UShortDrawElements", // 3
|
||||
"UIntDrawElements" // 4
|
||||
};
|
||||
|
||||
const char* Primitive::className() const
|
||||
{
|
||||
if (_primitiveType>=PrimitivePrimitiveType && _primitiveType<=UIntDrawElementsPrimitiveType)
|
||||
return s_PrimitiveNames[_primitiveType];
|
||||
else
|
||||
return "UnkownAttributeArray";
|
||||
glDrawArrays(_mode,_first,_count);
|
||||
}
|
||||
|
||||
void DrawArrays::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
functor.drawArrays(_mode,_first,_count);
|
||||
}
|
||||
|
||||
|
||||
void UByteDrawElements::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_BYTE,&front());
|
||||
}
|
||||
|
||||
void UByteDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
|
||||
void UShortDrawElements::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_SHORT,&front());
|
||||
}
|
||||
|
||||
void UShortDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UIntDrawElements::draw() const
|
||||
{
|
||||
glDrawElements(_mode,size(),GL_UNSIGNED_INT,&front());
|
||||
}
|
||||
|
||||
void UIntDrawElements::applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!empty()) functor.drawElements(_mode,size(),&front());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const char* Geometry_getBindingTypeStr(Geometry::AttributeBinding mode);
|
||||
bool Geometry_matchPrimitiveModeStr(const char* str,GLenum& mode);
|
||||
const char* Geometry_getPrimitiveModeStr(GLenum mode);
|
||||
|
||||
AttributeArray* AttributeArray_readLocalData(Input& fr);
|
||||
Array* Array_readLocalData(Input& fr);
|
||||
|
||||
bool Primitve_readLocalData(Input& fr,osg::Geometry& geom);
|
||||
|
||||
@@ -149,7 +149,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
if (fr.matchSequence("ColorArray %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
AttributeArray* colors = AttributeArray_readLocalData(fr);
|
||||
Array* colors = Array_readLocalData(fr);
|
||||
if (colors)
|
||||
{
|
||||
geom.setColorArray(colors);
|
||||
@@ -163,7 +163,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
fr[1].getInt(unit);
|
||||
|
||||
fr+=2;
|
||||
AttributeArray* texcoords = AttributeArray_readLocalData(fr);
|
||||
Array* texcoords = Array_readLocalData(fr);
|
||||
if (texcoords)
|
||||
{
|
||||
geom.setTexCoordArray(unit,texcoords);
|
||||
@@ -176,7 +176,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
|
||||
|
||||
AttributeArray* AttributeArray_readLocalData(Input& fr)
|
||||
Array* Array_readLocalData(Input& fr)
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
@@ -396,11 +396,11 @@ void Array_writeLocalData(Output& fw, Iterator first, Iterator last)
|
||||
|
||||
}
|
||||
|
||||
bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
{
|
||||
switch(array.arrayType())
|
||||
switch(array.getType())
|
||||
{
|
||||
case(ByteArrayType):
|
||||
case(Array::ByteArrayType):
|
||||
{
|
||||
const ByteArray& carray = static_cast<const ByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -408,7 +408,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(ShortArrayType):
|
||||
case(Array::ShortArrayType):
|
||||
{
|
||||
const ShortArray& carray = static_cast<const ShortArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -416,7 +416,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(IntArrayType):
|
||||
case(Array::IntArrayType):
|
||||
{
|
||||
const IntArray& carray = static_cast<const IntArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -424,7 +424,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UByteArrayType):
|
||||
case(Array::UByteArrayType):
|
||||
{
|
||||
const UByteArray& carray = static_cast<const UByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -432,7 +432,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UShortArrayType):
|
||||
case(Array::UShortArrayType):
|
||||
{
|
||||
const UShortArray& carray = static_cast<const UShortArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -440,7 +440,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UIntArrayType):
|
||||
case(Array::UIntArrayType):
|
||||
{
|
||||
const UIntArray& carray = static_cast<const UIntArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
@@ -448,7 +448,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UByte4ArrayType):
|
||||
case(Array::UByte4ArrayType):
|
||||
{
|
||||
const UByte4Array& carray = static_cast<const UByte4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
@@ -456,7 +456,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(FloatArrayType):
|
||||
case(Array::FloatArrayType):
|
||||
{
|
||||
const FloatArray& carray = static_cast<const FloatArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -464,7 +464,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Vec2ArrayType):
|
||||
case(Array::Vec2ArrayType):
|
||||
{
|
||||
const Vec2Array& carray = static_cast<const Vec2Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -472,7 +472,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Vec3ArrayType):
|
||||
case(Array::Vec3ArrayType):
|
||||
{
|
||||
const Vec3Array& carray = static_cast<const Vec3Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -480,7 +480,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Vec4ArrayType):
|
||||
case(Array::Vec4ArrayType):
|
||||
{
|
||||
const Vec4Array& carray = static_cast<const Vec4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
@@ -488,7 +488,7 @@ bool Array_writeLocalData(const AttributeArray& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(AttributeArrayType):
|
||||
case(Array::ArrayType):
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -617,16 +617,16 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
{
|
||||
|
||||
switch(prim.primitiveType())
|
||||
switch(prim.getType())
|
||||
{
|
||||
case(DrawArraysPrimitiveType):
|
||||
case(Primitive::DrawArraysPrimitiveType):
|
||||
{
|
||||
const DrawArrays& cprim = static_cast<const DrawArrays&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.getCount()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UByteDrawElementsPrimitiveType):
|
||||
case(Primitive::UByteDrawElementsPrimitiveType):
|
||||
{
|
||||
const UByteDrawElements& cprim = static_cast<const UByteDrawElements&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
@@ -634,7 +634,7 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UShortDrawElementsPrimitiveType):
|
||||
case(Primitive::UShortDrawElementsPrimitiveType):
|
||||
{
|
||||
const UShortDrawElements& cprim = static_cast<const UShortDrawElements&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
@@ -642,7 +642,7 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(UIntDrawElementsPrimitiveType):
|
||||
case(Primitive::UIntDrawElementsPrimitiveType):
|
||||
{
|
||||
const UIntDrawElements& cprim = static_cast<const UIntDrawElements&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
|
||||
Reference in New Issue
Block a user