diff --git a/CMakeModules/FindFreeType.cmake b/CMakeModules/FindFreeType.cmake index b42cd8ce4..0e16dd44a 100644 --- a/CMakeModules/FindFreeType.cmake +++ b/CMakeModules/FindFreeType.cmake @@ -25,6 +25,7 @@ # I'm going to attempt to cut out the middleman and hope # everything still works. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h + PATHS $ENV{FREETYPE_DIR} NO_DEFAULT_PATH PATH_SUFFIXES include diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 2a8dfb524..6c2802933 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -339,12 +339,12 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl // Is texture compiled for all active contexts? inline bool isCompiled(osg::Texture* texture) const { - using namespace std; - return (count_if(_activeGraphicsContexts.begin(), - _activeGraphicsContexts.end(), - bind1st(mem_fun(&osg::Texture::getTextureObject), - texture)) - == (int)_activeGraphicsContexts.size()); + for (ActiveGraphicsContexts::iterator iter=_activeGraphicsContexts.begin(); + iter!=_activeGraphicsContexts.end(); ++iter ) + { + if ( texture->getTextureObject(*iter) == NULL ) return false; + } + return true; } inline static bool isCompiled(const osg::StateSet* stateSet, @@ -364,20 +364,20 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl inline bool isCompiled(osg::StateSet* stateSet) { - using namespace std; for (unsigned i = 0; i < stateSet->getTextureAttributeList().size(); ++i) { osg::Texture* texture = dynamic_cast(stateSet->getTextureAttribute(i,osg::StateAttribute::TEXTURE)); - if (texture - && (count_if(_activeGraphicsContexts.begin(), - _activeGraphicsContexts.end(), - bind1st(mem_fun(&osg::Texture::getTextureObject), - texture)) - != (int)_activeGraphicsContexts.size())) - return false; + if (texture) + { + for (ActiveGraphicsContexts::iterator iter=_activeGraphicsContexts.begin(); + iter!=_activeGraphicsContexts.end(); ++iter ) + { + if ( texture->getTextureObject(*iter) == NULL ) return false; + } + } } return true; } @@ -395,14 +395,13 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl inline bool isCompiled(const osg::Drawable* drawable) const { - using namespace std; if (drawable->getUseDisplayList()) { - return (count_if(_activeGraphicsContexts.begin(), - _activeGraphicsContexts.end(), - bind1st(mem_fun(&osg::Drawable::getDisplayList), - drawable)) - == (int)_activeGraphicsContexts.size()); + for (ActiveGraphicsContexts::iterator iter=_activeGraphicsContexts.begin(); + iter!=_activeGraphicsContexts.end(); ++iter ) + { + if ( drawable->getDisplayList(*iter) == 0 ) return false; + } } return true; } diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index b93a3a30c..4aa44afb0 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -2630,7 +2630,7 @@ void Geometry::accept(PrimitiveIndexFunctor& functor) const return; } -unsigned int _computeNumberOfPrimitives(const osg::Geometry& geom) +static unsigned int _computeNumberOfPrimitives(const osg::Geometry& geom) { unsigned int totalNumberOfPrimitives = 0; diff --git a/src/osg/GraphicsContext.cpp b/src/osg/GraphicsContext.cpp index feae4cfd1..da78a70b1 100644 --- a/src/osg/GraphicsContext.cpp +++ b/src/osg/GraphicsContext.cpp @@ -35,32 +35,44 @@ using namespace osg; ///////////////////////////////////////////////////////////////////////////// -// -// GraphicsContext static method implementations -// -static ref_ptr s_WindowingSystemInterface; + +// Use a static reference pointer to hold the window system interface. +// Wrap this within a function, in order to control the order in which +// the static pointer's constructor is executed. + +static ref_ptr &windowingSystemInterfaceRef() +{ + static ref_ptr s_WindowingSystemInterface; + return s_WindowingSystemInterface; +} + + +// GraphicsContext static method implementations void GraphicsContext::setWindowingSystemInterface(WindowingSystemInterface* callback) { - s_WindowingSystemInterface = callback; - osg::notify(osg::INFO)<<"GraphicsContext::setWindowingSystemInterface() "< &wsref = windowingSystemInterfaceRef(); + wsref = callback; + osg::notify(osg::INFO)<<"GraphicsContext::setWindowingSystemInterface() "< &wsref = windowingSystemInterfaceRef(); + osg::notify(osg::INFO)<<"GraphicsContext::getWindowingSystemInterface() "< &wsref = windowingSystemInterfaceRef(); + if ( wsref.valid()) { // catch any undefined values. if (traits) traits->setUndefinedScreenDetailsToDefaultScreen(); - return s_WindowingSystemInterface->createGraphicsContext(traits); + return wsref->createGraphicsContext(traits); } else return 0; diff --git a/src/osgPlugins/Inventor/ConvertToInventor.cpp b/src/osgPlugins/Inventor/ConvertToInventor.cpp index 3e1c80410..667f9581e 100644 --- a/src/osgPlugins/Inventor/ConvertToInventor.cpp +++ b/src/osgPlugins/Inventor/ConvertToInventor.cpp @@ -210,7 +210,7 @@ void ConvertToInventor::apply(osg::Node &node) template -static void osgArray2ivMField_template(const osg::Array *array, fieldClass &field, int startIndex = 0, int stopIndex = 0, int numItemsUntilMinusOne = 0) +void osgArray2ivMField_template(const osg::Array *array, fieldClass &field, int startIndex = 0, int stopIndex = 0, int numItemsUntilMinusOne = 0) { int i,num = array->getNumElements(); if (startIndex!=0 || stopIndex!=0) { @@ -250,7 +250,7 @@ static void osgArray2ivMField_template(const osg::Array *array, fieldClass &fiel template -static void osgArray2ivMField_composite_template_worker(ivType *dest, osgType *src, int num, int numItemsUntilMinusOne = 0) +void osgArray2ivMField_composite_template_worker(ivType *dest, osgType *src, int num, int numItemsUntilMinusOne = 0) { for (int i=0; i -static void osgArray2ivMField_composite_template_worker(SbColor *dest, GLubyte *src, int num, int numItemsUntilMinusOne) +void osgArray2ivMField_composite_template_worker(SbColor *dest, GLubyte *src, int num, int numItemsUntilMinusOne) { for (int i=0; i(SbC template<> -static void osgArray2ivMField_composite_template_worker(SbVec3f *dest, float *src, int num, int numItemsUntilMinusOne) +void osgArray2ivMField_composite_template_worker(SbVec3f *dest, float *src, int num, int numItemsUntilMinusOne) { for (int i=0; i(SbVec template -static void osgArray2ivMField_composite_template(const osg::Array *array, fieldClass &field, int startIndex = 0, int stopIndex = 0, int numItemsUntilMinusOne = 0) +void osgArray2ivMField_composite_template(const osg::Array *array, fieldClass &field, int startIndex = 0, int stopIndex = 0, int numItemsUntilMinusOne = 0) { int num = array->getNumElements(); if (startIndex!=0 || stopIndex!=0) { @@ -295,7 +295,7 @@ static void osgArray2ivMField_composite_template(const osg::Array *array, fieldC template -static void osgArray2ivMField_pack_template(const osg::Array *array, fieldClass &field, +void osgArray2ivMField_pack_template(const osg::Array *array, fieldClass &field, osgType mul, osgType max, osgType min, int startIndex = 0, int stopIndex = 0, int numItemsUntilMinusOne = 0) { @@ -326,7 +326,7 @@ static void osgArray2ivMField_pack_template(const osg::Array *array, fieldClass template -static bool applicateIntType(const osg::Array *array, fieldClass &field, int startIndex, int stopIndex, int numItemsUntilMinusOne) +bool ivApplicateIntType(const osg::Array *array, fieldClass &field, int startIndex, int stopIndex, int numItemsUntilMinusOne) { if (field.isOfType(fieldClass::getClassTypeId())) { @@ -367,10 +367,10 @@ static void osgArray2ivMField(const osg::Array *array, SoMField &field, int star (array, (SoMFFloat&)field, startIndex, stopIndex, numItemsUntilMinusOne); return; } } - else if (applicateIntType(array, (SoMFInt32&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; - else if (applicateIntType(array, (SoMFUInt32&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; - else if (applicateIntType(array, (SoMFShort&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; - else if (applicateIntType(array, (SoMFUShort&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; + else if (ivApplicateIntType(array, (SoMFInt32&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; + else if (ivApplicateIntType(array, (SoMFUInt32&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; + else if (ivApplicateIntType(array, (SoMFShort&) field, startIndex, stopIndex, numItemsUntilMinusOne)) return; + else if (ivApplicateIntType(array, (SoMFUShort&)field, startIndex, stopIndex, numItemsUntilMinusOne)) return; else if (field.isOfType(SoMFVec2f::getClassTypeId())) { switch (array->getType()) @@ -415,7 +415,7 @@ static void osgArray2ivMField(const osg::Array *array, SoMField &field, int star template -static bool deindex(variableType *dest, const variableType *src, const int srcNum, +bool ivDeindex(variableType *dest, const variableType *src, const int srcNum, const indexType *indices, const int numToProcess) { for (int i=0; i -static bool deindex(variableType *dest, const variableType *src, const int srcNum, +bool ivDeindex(variableType *dest, const variableType *src, const int srcNum, const osg::Array *indices, const int numToProcess) { if (int(indices->getNumElements()) < numToProcess) { @@ -439,17 +439,17 @@ static bool deindex(variableType *dest, const variableType *src, const int srcNu switch (indices->getType()) { case osg::Array::ByteArrayType: case osg::Array::UByteArrayType: - return deindex(dest, src, srcNum, + return ivDeindex(dest, src, srcNum, (GLbyte*)indices->getDataPointer(), numToProcess); break; case osg::Array::ShortArrayType: case osg::Array::UShortArrayType: - return deindex(dest, src, srcNum, + return ivDeindex(dest, src, srcNum, (GLshort*)indices->getDataPointer(), numToProcess); break; case osg::Array::IntArrayType: case osg::Array::UIntArrayType: - return deindex(dest, src, srcNum, + return ivDeindex(dest, src, srcNum, (GLint*)indices->getDataPointer(), numToProcess); break; default: @@ -460,7 +460,7 @@ static bool deindex(variableType *dest, const variableType *src, const int srcNu template -static bool processArray(const osg::Array *indices, const osg::Array *drawElemIndices, +bool ivProcessArray(const osg::Array *indices, const osg::Array *drawElemIndices, fieldType *destField, const fieldType *srcField, int startIndex, int numToProcess) { @@ -470,11 +470,11 @@ static bool processArray(const osg::Array *indices, const osg::Array *drawElemIn // "deindex" original data if (indices && !drawElemIndices) - ok = deindex(destField->startEditing(), + ok = ivDeindex(destField->startEditing(), srcField->getValues(startIndex), srcField->getNum(), indices, numToProcess); else if (!indices && drawElemIndices) - ok = deindex(destField->startEditing(), + ok = ivDeindex(destField->startEditing(), srcField->getValues(startIndex), srcField->getNum(), drawElemIndices, numToProcess); else { @@ -1197,7 +1197,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet nonIndexedCoords = new SoCoordinate4; if (ok) { ((SoCoordinate4*)nonIndexedCoords)->point.setNum(n); - ok = processArray(g->getVertexIndices(), + ok = ivProcessArray(g->getVertexIndices(), drawElemIndices, &((SoCoordinate4*)nonIndexedCoords)->point, &((SoCoordinate4*)ivCoords)->point, @@ -1207,7 +1207,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet nonIndexedCoords = new SoCoordinate3; if (ok) { ((SoCoordinate3*)nonIndexedCoords)->point.setNum(n); - ok = processArray(g->getVertexIndices(), + ok = ivProcessArray(g->getVertexIndices(), drawElemIndices, &((SoCoordinate3*)nonIndexedCoords)->point, &((SoCoordinate3*)ivCoords)->point, @@ -1221,7 +1221,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet nonIndexedTexCoords = new SoTextureCoordinate2; if (ok) { ((SoTextureCoordinate2*)nonIndexedTexCoords)->point.setNum(n); - ok = processArray(g->getTexCoordIndices(0), + ok = ivProcessArray(g->getTexCoordIndices(0), drawElemIndices, &((SoTextureCoordinate2*)nonIndexedTexCoords)->point, &((SoTextureCoordinate2*)ivTexCoords)->point, @@ -1232,7 +1232,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet nonIndexedTexCoords = new SoTextureCoordinate3; if (ok) { ((SoTextureCoordinate3*)nonIndexedTexCoords)->point.setNum(n); - ok = processArray(g->getTexCoordIndices(0), + ok = ivProcessArray(g->getTexCoordIndices(0), drawElemIndices, &((SoTextureCoordinate3*)nonIndexedTexCoords)->point, &((SoTextureCoordinate3*)ivCoords)->point, @@ -1246,7 +1246,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet nonIndexedNormals = new SoNormal; if (ok) { nonIndexedNormals->vector.setNum(numNormalsUsed==0 ? 1 : numNormalsUsed); - ok = processArray(g->getNormalIndices(), + ok = ivProcessArray(g->getNormalIndices(), g->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL, &nonIndexedNormals->vector, &ivNormals->vector, normalStart, numNormalsUsed==0 ? 1 : numNormalsUsed); @@ -1269,7 +1269,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet &((SoMaterial*)ivMaterial)->diffuseColor : &((SoBaseColor*)ivMaterial)->rgb; dstColorField->setNum(numColorsUsed==0 ? 1 : numColorsUsed); - ok = processArray(g->getColorIndices(), + ok = ivProcessArray(g->getColorIndices(), g->getColorBinding()==osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL, dstColorField, srcColorField, colorStart, numColorsUsed==0 ? 1 : numColorsUsed); diff --git a/src/osgUtil/Tessellator.cpp b/src/osgUtil/Tessellator.cpp index b40b8da56..1b5be2df7 100644 --- a/src/osgUtil/Tessellator.cpp +++ b/src/osgUtil/Tessellator.cpp @@ -600,7 +600,7 @@ void Tessellator::reduceArray(osg::Array * cold, const unsigned int nnu) } } -unsigned int _computeNumberOfPrimitives(const osg::Geometry& geom) +static unsigned int _computeNumberOfPrimitives(const osg::Geometry& geom) { unsigned int totalNumberOfPrimitives = 0;