Work on supporting multitexturing in State/StateSet/StateAttribute/Geoemtry.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user