Tidied up the types in osg::GeoSet so that the index pointers use GLushort

and GLuint to get round compile issues under MacOSX.
This commit is contained in:
Robert Osfield
2002-07-10 22:33:08 +00:00
parent 8b1e9345df
commit 5d18f0ee11
4 changed files with 54 additions and 52 deletions

View File

@@ -481,7 +481,7 @@ public:
{
if (indices==0 || count==0) return;
typedef unsigned char* IndexPointer;
typedef GLubyte* IndexPointer;
switch(mode)
{
@@ -548,7 +548,7 @@ public:
{
if (indices==0 || count==0) return;
typedef unsigned short* IndexPointer;
typedef GLushort* IndexPointer;
switch(mode)
{
@@ -617,7 +617,7 @@ public:
{
if (indices==0 || count==0) return;
typedef unsigned int* IndexPointer;
typedef GLuint* IndexPointer;
switch(mode)
{

View File

@@ -84,11 +84,11 @@ class SG_EXPORT GeoSet : public Drawable
bool _is_ushort;
union
{
ushort* _ushort;
uint* _uint;
GLushort* _ushort;
GLuint* _uint;
} _ptr;
IndexPointer() { _size=0;_is_ushort=true;_ptr._ushort = (ushort*)0; }
IndexPointer() { _size=0;_is_ushort=true;_ptr._ushort = (GLushort*)0; }
inline const bool operator == (const IndexPointer& ip) const
{
@@ -99,22 +99,22 @@ class SG_EXPORT GeoSet : public Drawable
inline const bool valid() const
{
return _ptr._ushort != (ushort*)0;
return _ptr._ushort != (GLushort*)0;
}
inline const bool null() const
{
return _ptr._ushort == (ushort*)0;
return _ptr._ushort == (GLushort*)0;
}
inline void setToNull()
{
_size = 0;
_is_ushort = true;
_ptr._ushort = (ushort*)0;
_ptr._ushort = (GLushort*)0;
}
inline void set(uint size,ushort* data)
inline void set(uint size,GLushort* data)
{
_size = size;
_is_ushort = true;
@@ -122,7 +122,7 @@ class SG_EXPORT GeoSet : public Drawable
}
void set(const uint size,uint* data)
void set(const uint size,GLuint* data)
{
_size = size;
_is_ushort = false;
@@ -145,7 +145,7 @@ class SG_EXPORT GeoSet : public Drawable
return max;
}
inline const uint operator [] (const uint pos) const
inline const GLint operator [] (const GLuint pos) const
{
if (_is_ushort) return _ptr._ushort[pos];
else return _ptr._uint[pos];
@@ -199,11 +199,11 @@ class SG_EXPORT GeoSet : public Drawable
/** set the coords (i.e the geometry) and ushort indices of the geoset.
To reduce memory footprint and bandwidth for small datasets it is
recommended the ushort indices are used instead of unit indices.*/
void setCoords( Vec3 *cp, ushort *ci );
void setCoords( Vec3 *cp, GLushort *ci );
/** set the coords (i.e the geometry) and uint indices of the geoset.
Unless your data set exceeds 65536 indices prefer ushort indices
over uint indices, only use this unit indices version if necessary.*/
void setCoords( Vec3 *cp, uint *ci );
void setCoords( Vec3 *cp, GLuint *ci );
/** set the coords (i.e the geometry) and indices of the geoset.*/
void setCoords( Vec3 *cp, IndexPointer& ip );
@@ -222,9 +222,9 @@ class SG_EXPORT GeoSet : public Drawable
/** set the normals of the geoset.*/
void setNormals( Vec3 *np );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, ushort *ni );
void setNormals( Vec3 *np, GLushort *ni );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, uint *ni );
void setNormals( Vec3 *np, GLuint *ni );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, IndexPointer& ip );
/** set the normals binding to the vertices/primitives/overall.*/
@@ -246,9 +246,9 @@ class SG_EXPORT GeoSet : public Drawable
/** set the colors of the geoset.*/
void setColors( Vec4 *cp );
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, ushort *li );
void setColors( Vec4 *cp, GLushort *li );
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, uint *li );
void setColors( Vec4 *cp, GLuint *li );
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, IndexPointer& ip );
/** set the color binding to the vertices/primitives/overall.*/
@@ -270,9 +270,9 @@ class SG_EXPORT GeoSet : public Drawable
/** set the texture coords of the geoset.*/
void setTextureCoords( Vec2 *tc );
/** set the texture coords and texture coord indices of the geoset.*/
void setTextureCoords( Vec2 *tc, ushort *ti );
void setTextureCoords( Vec2 *tc, GLushort *ti );
/** set the texture coords and texture coord indices of the geoset.*/
void setTextureCoords( Vec2 *tc, uint *ti );
void setTextureCoords( Vec2 *tc, GLuint *ti );
/** set the texture coords and texture indices of the geoset.*/
void setTextureCoords( Vec2 *tc, IndexPointer& ip );
/** set the texture coord binding to the vertices/primitives/overall.*/
@@ -296,8 +296,8 @@ class SG_EXPORT GeoSet : public Drawable
/** set the interleaved arrays of the geoset.*/
void setInterleavedArray( const InterleaveArrayType format, float *ia );
void setInterleavedArray( const InterleaveArrayType format, float *ia, ushort *iai );
void setInterleavedArray( const InterleaveArrayType format, float *ia, uint *iai );
void setInterleavedArray( const InterleaveArrayType format, float *ia, GLushort *iai );
void setInterleavedArray( const InterleaveArrayType format, float *ia, GLuint *iai );
void setInterleavedArray( const InterleaveArrayType format, float *ia, IndexPointer& iai );
/** draw geoset directly ignoring an OpenGL display list which could be attached.
@@ -414,13 +414,13 @@ void for_each_triangle(GeoSet& gset,T& op)
{
if (gset.getCoordIndices()._is_ushort)
{
ushort* iptr = gset.getCoordIndices()._ptr._ushort;
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
ushort* iend = iptr+primLength;
GLushort* iend = iptr+primLength;
for(int j = 2; j < primLength; j++ )
{
if( !(j%2) )
@@ -434,13 +434,13 @@ void for_each_triangle(GeoSet& gset,T& op)
}
else
{
uint* iptr = gset.getCoordIndices()._ptr._uint;
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
uint* iend = iptr+primLength;
GLuint* iend = iptr+primLength;
for(int j = 2; j < primLength; j++ )
{
if( !(j%2) )
@@ -481,7 +481,7 @@ void for_each_triangle(GeoSet& gset,T& op)
{
if (gset.getCoordIndices()._is_ushort)
{
ushort* iptr = gset.getCoordIndices()._ptr._ushort;
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -492,7 +492,7 @@ void for_each_triangle(GeoSet& gset,T& op)
}
else
{
uint* iptr = gset.getCoordIndices()._ptr._uint;
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -521,13 +521,13 @@ void for_each_triangle(GeoSet& gset,T& op)
{
if (gset.getCoordIndices()._is_ushort)
{
ushort* iptr = gset.getCoordIndices()._ptr._ushort;
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
ushort* iend = iptr+primLength;
GLushort* iend = iptr+primLength;
for(int j = 3; j < primLength; j+=2 )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
@@ -539,13 +539,13 @@ void for_each_triangle(GeoSet& gset,T& op)
}
else
{
uint* iptr = gset.getCoordIndices()._ptr._uint;
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
uint* iend = iptr+primLength;
GLuint* iend = iptr+primLength;
for(int j = 3; j < primLength; j+=2 )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
@@ -581,7 +581,7 @@ void for_each_triangle(GeoSet& gset,T& op)
{
if (gset.getCoordIndices()._is_ushort)
{
ushort* iptr = gset.getCoordIndices()._ptr._ushort;
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -593,7 +593,7 @@ void for_each_triangle(GeoSet& gset,T& op)
}
else
{
uint* iptr = gset.getCoordIndices()._ptr._uint;
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -626,7 +626,7 @@ void for_each_triangle(GeoSet& gset,T& op)
{
if (gset.getCoordIndices()._is_ushort)
{
ushort* iptr = gset.getCoordIndices()._ptr._ushort;
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -648,7 +648,7 @@ void for_each_triangle(GeoSet& gset,T& op)
}
else
{
uint* iptr = gset.getCoordIndices()._ptr._uint;
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
@@ -657,7 +657,7 @@ void for_each_triangle(GeoSet& gset,T& op)
if (primLength>0)
{
const Vec3& start = vptr[*(iptr)];
uint* iend = iptr+primLength;
GLuint* iend = iptr+primLength;
++iptr;
for(int j = 2; j < primLength; ++j )
{

View File

@@ -160,8 +160,8 @@ void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset)
// coord indicies may be shared so we have to go through the long winded
// step of creating unique pointer sets which we then delete. This
// ensures that arrays aren't osgDelete twice. Robert.
std::set<osg::ushort*> ushortList;
std::set<osg::uint*> uintList;
std::set<GLushort*> ushortList;
std::set<GLuint*> uintList;
INDEX_ARRAY_DELETE(gset->getCoordIndices())
INDEX_ARRAY_DELETE(gset->getNormalIndices());
@@ -169,14 +169,14 @@ void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset)
INDEX_ARRAY_DELETE(gset->getTextureIndices())
INDEX_ARRAY_DELETE(gset->getInterleavedIndices());
for(std::set<osg::ushort*>::iterator sitr=ushortList.begin();
for(std::set<GLushort*>::iterator sitr=ushortList.begin();
sitr!=ushortList.end();
++sitr)
{
osgDelete [] *sitr;
}
for(std::set<osg::uint*>::iterator iitr=uintList.begin();
for(std::set<GLuint*>::iterator iitr=uintList.begin();
iitr!=uintList.end();
++iitr)
{
@@ -594,7 +594,7 @@ void GeoSet::setCoords( Vec3 *cp )
}
void GeoSet::setCoords( Vec3 *cp, ushort *ci )
void GeoSet::setCoords( Vec3 *cp, GLushort *ci )
{
_coords = cp;
// note the size of cindex defaults 0, but will be recalculated
@@ -605,7 +605,7 @@ void GeoSet::setCoords( Vec3 *cp, ushort *ci )
}
void GeoSet::setCoords( Vec3 *cp, uint *ci )
void GeoSet::setCoords( Vec3 *cp, GLuint *ci )
{
_coords = cp;
// note the size of cindex defaults 0, but will be recalculated
@@ -634,7 +634,7 @@ void GeoSet::setNormals( Vec3 *np )
}
void GeoSet::setNormals( Vec3 *np, ushort *ni )
void GeoSet::setNormals( Vec3 *np, GLushort *ni )
{
_normals = np;
// note the size of nindex defaults 0, but will be recalculated
@@ -646,7 +646,7 @@ void GeoSet::setNormals( Vec3 *np, ushort *ni )
set_fast_path();
}
void GeoSet::setNormals( Vec3 *np, uint *ni )
void GeoSet::setNormals( Vec3 *np, GLuint *ni )
{
_normals = np;
// note the size of nindex defaults 0, but will be recalculated
@@ -681,7 +681,7 @@ void GeoSet::setColors( Vec4 *lp )
}
void GeoSet::setColors( Vec4 *lp, ushort *coli )
void GeoSet::setColors( Vec4 *lp, GLushort *coli )
{
_colors = lp;
// note the size of colindex defaults 0, but will be recalculated
@@ -693,7 +693,7 @@ void GeoSet::setColors( Vec4 *lp, ushort *coli )
set_fast_path();
}
void GeoSet::setColors( Vec4 *lp, uint *coli )
void GeoSet::setColors( Vec4 *lp, GLuint *coli )
{
_colors = lp;
// note the size of colindex defaults 0, but will be recalculated
@@ -728,7 +728,7 @@ void GeoSet::setTextureCoords( Vec2 *tc )
}
void GeoSet::setTextureCoords( Vec2 *tc, ushort *ti )
void GeoSet::setTextureCoords( Vec2 *tc, GLushort *ti )
{
_tcoords = tc;
// note the size of tindex defaults 0, but will be recalculated
@@ -741,7 +741,7 @@ void GeoSet::setTextureCoords( Vec2 *tc, ushort *ti )
}
void GeoSet::setTextureCoords( Vec2 *tc, uint *ti )
void GeoSet::setTextureCoords( Vec2 *tc, GLuint *ti )
{
_tcoords = tc;
// note the size of tindex defaults 0, but will be recalculated

View File

@@ -3,6 +3,8 @@
#include <osg/GLU>
#include <algorithm>
using namespace osg;
State::State()
@@ -188,9 +190,9 @@ void State::apply(const StateSet* dstate)
const StateSet::TextureAttributeList& ds_textureAttributeList = dstate->getTextureAttributeList();
unsigned int unit;
unsigned int unitMax = std::max(ds_textureModeList.size(),ds_textureAttributeList.size());
unitMax = std::max(unitMax,_textureModeMapList.size());
unitMax = std::max(unitMax,_textureAttributeMapList.size());
unsigned int unitMax = std::max(static_cast<unsigned int>(ds_textureModeList.size()),static_cast<unsigned int>(ds_textureAttributeList.size()));
unitMax = std::max(static_cast<unsigned int>(unitMax),static_cast<unsigned int>(_textureModeMapList.size()));
unitMax = std::max(static_cast<unsigned int>(unitMax),static_cast<unsigned int>(_textureAttributeMapList.size()));
for(unit=0;unit<unitMax;++unit)
{
if (setActiveTextureUnit(unit))