diff --git a/CMakeLists.txt b/CMakeLists.txt index 51716adb..54d9901c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,7 +240,7 @@ else() endif() endif(ENABLE_SOUND) - find_package(OpenSceneGraph 3.2.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgViewer osgUtil) + find_package(OpenSceneGraph 3.4.1 REQUIRED osgText osgSim osgDB osgParticle osgGA osgViewer osgUtil) if (MSVC) set(CMAKE_REQUIRED_INCLUDES ${OPENSCENEGRAPH_INCLUDE_DIRS}) diff --git a/simgear/canvas/ODGauge.cxx b/simgear/canvas/ODGauge.cxx index 12bb52d2..b5987c67 100644 --- a/simgear/canvas/ODGauge.cxx +++ b/simgear/canvas/ODGauge.cxx @@ -45,7 +45,6 @@ #include #include #include // for GL_DEPTH_STENCIL_EXT on Windows -#include #include #include @@ -276,11 +275,7 @@ namespace canvas { osg::NodeCallback* cull_callback = camera -#if OSG_VERSION_LESS_THAN(3,3,2) - ? camera->getCullCallback() -#else ? dynamic_cast(camera->getCullCallback()) -#endif : 0; clear(); diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 7b564737..1ac4d5e6 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -365,13 +364,7 @@ namespace canvas // Drawables have a bounding box... if( _drawable ) - return _drawable-> -#if OSG_VERSION_LESS_THAN(3,3,2) - getBound() -#else - getBoundingBox() -#endif - .contains(osg::Vec3f(local_pos, 0)); + return _drawable->getBoundingBox().contains(osg::Vec3f(local_pos, 0)); else if( _scene_group.valid() ) // ... for other elements, i.e. groups only a bounding sphere is available return _scene_group->getBound().contains(osg::Vec3f(parent_pos, 0)); @@ -643,11 +636,7 @@ namespace canvas osg::BoundingBox Element::getBoundingBox() const { if( _drawable ) -#if OSG_VERSION_LESS_THAN(3,3,2) - return _drawable->getBound(); -#else return _drawable->getBoundingBox(); -#endif osg::BoundingBox bb; @@ -670,12 +659,7 @@ namespace canvas return osg::BoundingBox(); osg::BoundingBox transformed; - const osg::BoundingBox& bb = -#if OSG_VERSION_LESS_THAN(3,3,2) - _drawable->getBound(); -#else - _drawable->getBoundingBox(); -#endif + const osg::BoundingBox& bb = _drawable->getBoundingBox(); for(int i = 0; i < 4; ++i) transformed.expandBy( bb.corner(i) * m ); diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx index bb517099..883a70b8 100644 --- a/simgear/canvas/elements/CanvasImage.cxx +++ b/simgear/canvas/elements/CanvasImage.cxx @@ -179,13 +179,7 @@ namespace canvas && child->getNameString() == "visible" && child->getBoolValue() ) { - CullCallback* cb = -#if OSG_VERSION_LESS_THAN(3,3,2) - static_cast -#else - dynamic_cast -#endif - ( _geom->getCullCallback() ); + CullCallback* cb = dynamic_cast( _geom->getCullCallback() ); if( cb ) cb->cullNextFrame(); diff --git a/simgear/canvas/elements/CanvasPath.cxx b/simgear/canvas/elements/CanvasPath.cxx index ae083e84..90057c85 100644 --- a/simgear/canvas/elements/CanvasPath.cxx +++ b/simgear/canvas/elements/CanvasPath.cxx @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -559,12 +558,8 @@ namespace canvas /** * Compute the bounding box */ - osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) - computeBound() -#else - computeBoundingBox() -#endif + osg::BoundingBox computeBoundingBox() + const override { if( _path == VG_INVALID_HANDLE || (_attributes_dirty & PATH) ) diff --git a/simgear/canvas/elements/CanvasText.cxx b/simgear/canvas/elements/CanvasText.cxx index 9f7a54d7..bdea9d7a 100644 --- a/simgear/canvas/elements/CanvasText.cxx +++ b/simgear/canvas/elements/CanvasText.cxx @@ -61,11 +61,7 @@ namespace canvas SGVec2i sizeForWidth(int w); #endif -#if OSG_VERSION_LESS_THAN(3,3,2) - osg::BoundingBox computeBound() const override; -#else osg::BoundingBox computeBoundingBox() const override; -#endif protected: friend class TextLine; @@ -173,13 +169,9 @@ namespace canvas #if OSG_VERSION_GREATER_OR_EQUAL(3,5,6) // TODO: need 3.5.6 version of this. -#else -#if OSG_VERSION_LESS_THAN(3,3,5) - GlyphQuads::Coords2 const& coords = _quads->_coords; #else GlyphQuads::Coords2 refCoords = _quads->_coords; GlyphQuads::Coords2::element_type &coords = *refCoords.get(); -#endif size_t global_i = _begin + i; @@ -217,13 +209,9 @@ namespace canvas #if OSG_VERSION_GREATER_OR_EQUAL(3,5,6) // TODO: need 3.5.7 version of this. return cursorPos(0); -#else -#if OSG_VERSION_LESS_THAN(3,3,5) - GlyphQuads::Coords2 const& coords = _quads->_coords; #else GlyphQuads::Coords2 refCoords = _quads->_coords; GlyphQuads::Coords2::element_type &coords = *refCoords.get(); -#endif GlyphQuads::Glyphs const& glyphs = _quads->_glyphs; @@ -649,28 +637,9 @@ namespace canvas } //---------------------------------------------------------------------------- -#if OSG_VERSION_LESS_THAN(3,3,2) - osg::BoundingBox Text::TextOSG::computeBound() const -#else osg::BoundingBox Text::TextOSG::computeBoundingBox() const -#endif { -#if OSG_VERSION_LESS_THAN(3,3,2) - osg::BoundingBox bb = osgText::Text::computeBound(); -#else - osg::BoundingBox bb = osgText::Text::computeBoundingBox(); -#endif - -#if OSG_VERSION_LESS_THAN(3,1,0) - if( bb.valid() ) - { - // TODO bounding box still doesn't seem always right (eg. with center - // horizontal alignment not completely accurate) - bb._min.y() += _offset.y(); - bb._max.y() += _offset.y(); - } -#endif - + osg::BoundingBox bb = osgText::Text::computeBoundingBox(); return bb; } @@ -685,12 +654,8 @@ namespace canvas const GlyphQuads& quads = _textureGlyphQuadMap.begin()->second; const GlyphQuads::Glyphs& glyphs = quads._glyphs; -#if OSG_VERSION_LESS_THAN(3,3,5) - GlyphQuads::Coords2 const& coords = quads._coords; -#else GlyphQuads::Coords2 refCoords = quads._coords; GlyphQuads::Coords2::element_type &coords = *refCoords.get(); -#endif const GlyphQuads::LineNumbers& line_numbers = quads._lineNumbers; diff --git a/simgear/scene/material/EffectGeode.hxx b/simgear/scene/material/EffectGeode.hxx index e4b024b7..ed746063 100644 --- a/simgear/scene/material/EffectGeode.hxx +++ b/simgear/scene/material/EffectGeode.hxx @@ -18,7 +18,6 @@ #define SIMGEAR_EFFECT_GEODE_HXX 1 #include -#include #include @@ -31,9 +30,6 @@ class EffectGeode : public osg::Geode { public: -#if OSG_VERSION_LESS_THAN(3,3,2) - typedef DrawableList::iterator DrawablesIterator; -#else class DrawablesIterator: public boost::iterator_adaptor< DrawablesIterator, @@ -62,7 +58,6 @@ class EffectGeode : public osg::Geode return base_reference()->get()->asDrawable(); } }; -#endif EffectGeode(); EffectGeode(const EffectGeode& rhs, @@ -75,13 +70,9 @@ class EffectGeode : public osg::Geode virtual void resizeGLObjectBuffers(unsigned int maxSize); virtual void releaseGLObjects(osg::State* = 0) const; -#if OSG_VERSION_LESS_THAN(3,3,2) - DrawablesIterator drawablesBegin() { return _drawables.begin(); } - DrawablesIterator drawablesEnd() { return _drawables.end(); } -#else + DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); } DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); } -#endif void runGenerators(osg::Geometry *geometry); private: diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx index 30f8db74..bc2dae24 100644 --- a/simgear/scene/material/Technique.cxx +++ b/simgear/scene/material/Technique.cxx @@ -142,14 +142,9 @@ Technique::processDrawables(const EffectGeode::DrawablesIterator& begin, { Drawable* drawable = itr->get(); -#if OSG_VERSION_LESS_THAN(3,3,2) - const BoundingBox& bb = drawable->getBound(); - osg::Drawable::CullCallback* cull = drawable->getCullCallback(); -#else const BoundingBox& bb = drawable->getBoundingBox(); osg::Drawable::CullCallback* cull = dynamic_cast(drawable->getCullCallback()); -#endif if( (cull && cull->cull(cv, drawable, &cv->getRenderInfo())) || (isCullingActive && cv->isCulled(bb)) ) @@ -322,15 +317,9 @@ public: = GL2Extensions::Get(static_cast(contextId), true); if (!extensions) return; -#if OSG_VERSION_LESS_THAN(3,3,4) - if (!extensions->isGlslSupported()) - return; - value = extensions->getLanguageVersion(); -#else if (!extensions->isGlslSupported) return; value = extensions->glslLanguageVersion; -#endif } }; @@ -359,11 +348,7 @@ public: = GL2Extensions::Get(static_cast(contextId), true); if (!extensions) return; -#if OSG_VERSION_LESS_THAN(3,3,4) - value = extensions->isGlslSupported(); -#else value = extensions->isGlslSupported; -#endif } }; diff --git a/simgear/scene/material/TextureBuilder.cxx b/simgear/scene/material/TextureBuilder.cxx index 25fab866..70ad0a08 100644 --- a/simgear/scene/material/TextureBuilder.cxx +++ b/simgear/scene/material/TextureBuilder.cxx @@ -273,11 +273,7 @@ bool setAttrs(const TexTuple& attrs, Texture* tex, options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS_NORMALIZED); else options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); -#if OSG_VERSION_LESS_THAN(3,4,2) - result = osgDB::readImageFile(imageName, options); -#else result = osgDB::readRefImageFile(imageName, options); -#endif options->setLoadOriginHint(origLOH); osg::ref_ptr image; if (result.success()) @@ -607,56 +603,34 @@ Texture* CubeMapBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode* SGReaderWriterOptions* wOpts = (SGReaderWriterOptions*)options; SGReaderWriterOptions::LoadOriginHint origLOH = wOpts->getLoadOriginHint(); wOpts->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<0>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<0>(_tuple), options); -#endif + if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image); } -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<1>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<1>(_tuple), options); -#endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image); } -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<2>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<2>(_tuple), options); -#endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image); } -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<3>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<3>(_tuple), options); -#endif + if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image); } -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<4>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<4>(_tuple), options); -#endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image); } -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(std::get<5>(_tuple), options); -#else result = osgDB::readRefImageFile(std::get<5>(_tuple), options); -#endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image); @@ -681,11 +655,8 @@ Texture* CubeMapBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode* return cubeTexture.release(); osgDB::ReaderWriter::ReadResult result; -#if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(texname, options); -#else result = osgDB::readRefImageFile(texname, options); -#endif + if(result.success()) { osg::Image* image = result.getImage(); image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones @@ -812,11 +783,7 @@ Texture* Texture3DBuilder::build(Effect* effect, Pass* pass, options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS_NORMALIZED); else options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); -#if OSG_VERSION_LESS_THAN(3,4,2) - result = osgDB::readImageFile(imageName, options); -#else result = osgDB::readRefImageFile(imageName, options); -#endif options->setLoadOriginHint(origLOH); osg::ref_ptr image; if (result.success()) diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index d2b1d9cc..1768c158 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -226,11 +226,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options, } else { -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::Image* image = osgDB::readImageFile(fullMaskPath, options); -#else osg::Image* image = osgDB::readRefImageFile(fullMaskPath, options); -#endif if (image && image->valid()) { Texture2DRef object_mask = new osg::Texture2D; diff --git a/simgear/scene/model/BVHPageNodeOSG.cxx b/simgear/scene/model/BVHPageNodeOSG.cxx index 326585ab..9c4b13be 100644 --- a/simgear/scene/model/BVHPageNodeOSG.cxx +++ b/simgear/scene/model/BVHPageNodeOSG.cxx @@ -216,11 +216,7 @@ public: if (pagedLOD.getMinRange(i) <= 0) { osg::ref_ptr options; options = getOptions(pagedLOD.getDatabaseOptions(), pagedLOD.getDatabasePath()); -#if OSG_VERSION_LESS_THAN(3,4,0) - node = osgDB::readNodeFile(pagedLOD.getFileName(i), options.get()); -#else node = osgDB::readRefNodeFile(pagedLOD.getFileName(i), options.get()); -#endif } if (!node.valid()) node = new osg::Group; @@ -261,11 +257,7 @@ public: osg::ref_ptr options; options = getOptions(proxyNode.getDatabaseOptions(), proxyNode.getDatabasePath()); osg::ref_ptr node; -#if OSG_VERSION_LESS_THAN(3,4,0) - node = osgDB::readNodeFile(proxyNode.getFileName(i), options.get()); -#else node = osgDB::readRefNodeFile(proxyNode.getFileName(i), options.get()); -#endif if (!node.valid()) node = new osg::Group; if (i < proxyNode.getNumChildren()) @@ -362,11 +354,8 @@ SGSharedPtr BVHPageNodeOSG::load(const std::string& name, const osg::ref_ptr& options) { osg::ref_ptr node; -#if OSG_VERSION_LESS_THAN(3,4,0) - node = osgDB::readNodeFile(name, dynamic_cast(options.get())); -#else node = osgDB::readRefNodeFile(name, dynamic_cast(options.get())); -#endif + if (!node.valid()) return SGSharedPtr(); diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index b2789bcd..92a09bca 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -586,11 +586,7 @@ ModelRegistry::readImage(const string& fileName, osg::ref_ptr DefaultCachePolicy::find(const string& fileName, const Options* opt) { Registry* registry = Registry::instance(); -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::ref_ptr cachedObject = registry->getFromObjectCache(fileName); -#else osg::ref_ptr cachedObject = registry->getRefFromObjectCache(fileName); -#endif ref_ptr cachedNode = dynamic_cast(cachedObject.get()); if (cachedNode.valid()) diff --git a/simgear/scene/model/SGReaderWriterXML.cxx b/simgear/scene/model/SGReaderWriterXML.cxx index 91f5bd11..f04c84b3 100644 --- a/simgear/scene/model/SGReaderWriterXML.cxx +++ b/simgear/scene/model/SGReaderWriterXML.cxx @@ -338,11 +338,8 @@ sgLoad3DModel_internal(const SGPath& path, options->setDatabasePath(texturepath.utf8Str()); osgDB::ReaderWriter::ReadResult modelResult; -#if OSG_VERSION_LESS_THAN(3,4,1) - modelResult = osgDB::readNodeFile(modelpath.utf8Str(), options.get()); -#else modelResult = osgDB::readRefNodeFile(modelpath.utf8Str(), options.get()); -#endif + if (!modelResult.validNode()) throw sg_io_exception("Failed to load 3D model:" + modelResult.message(), modelpath); diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 81f4e9e0..228c2187 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -41,17 +41,9 @@ SGLoadTexture2D(bool staticTexture, const std::string& path, { osg::ref_ptr image; if (options) -#if OSG_VERSION_LESS_THAN(3,4,0) - image = osgDB::readImageFile(path, options); -#else image = osgDB::readRefImageFile(path, options); -#endif else -#if OSG_VERSION_LESS_THAN(3,4,0) - image = osgDB::readImageFile(path); -#else image = osgDB::readRefImageFile(path); -#endif osg::ref_ptr texture = new osg::Texture2D; texture->setImage(image); @@ -152,11 +144,7 @@ Texture2D* TextureUpdateVisitor::textureReplace(int unit, const StateAttribute* if (fullLiveryFile.empty() || fullLiveryFile == *fullFilePath) return 0; -#if OSG_VERSION_LESS_THAN(3,4,0) - Image* newImage = readImageFile(fullLiveryFile); -#else osg::ref_ptr newImage = readRefImageFile(fullLiveryFile); -#endif if (!newImage) return 0; @@ -166,11 +154,7 @@ Texture2D* TextureUpdateVisitor::textureReplace(int unit, const StateAttribute* return 0; newTexture->setImage(newImage); -#if OSG_VERSION_LESS_THAN(3,4,0) - if (newImage->valid()) -#else if (newImage.valid()) -#endif { newTexture->setMaxAnisotropy(SGSceneFeatures::instance()->getTextureFilter()); } diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx index 1dd32459..fe8f84d3 100644 --- a/simgear/scene/model/modellib.cxx +++ b/simgear/scene/model/modellib.cxx @@ -116,11 +116,7 @@ osg::Node* loadFile(const string& path, SGReaderWriterOptions* options) options->setInstantiateEffects(true); } -#if OSG_VERSION_LESS_THAN(3,4,0) - ref_ptr model = readNodeFile(path, options); -#else ref_ptr model = readRefNodeFile(path, options); -#endif if (!model) return 0; else diff --git a/simgear/scene/model/particles.cxx b/simgear/scene/model/particles.cxx index 1b055127..a322484e 100644 --- a/simgear/scene/model/particles.cxx +++ b/simgear/scene/model/particles.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 39a46ddd..2d50fb81 100644 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -128,11 +128,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const sortData.frameSorted = frameNumber; } -#if OSG_VERSION_LESS_THAN(3,3,4) - const Extensions* extensions = getExtensions(state.getContextID(),true); -#else const GLExtensions* extensions = GLExtensions::Get(state.getContextID(), true); -#endif GLfloat ua1[3] = { (GLfloat) alpha_factor, (GLfloat) shade_factor, (GLfloat) cloud_height }; diff --git a/simgear/scene/sky/CloudShaderGeometry.hxx b/simgear/scene/sky/CloudShaderGeometry.hxx index 82eb99c8..7ac06c61 100644 --- a/simgear/scene/sky/CloudShaderGeometry.hxx +++ b/simgear/scene/sky/CloudShaderGeometry.hxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -98,13 +97,7 @@ class CloudShaderGeometry : public osg::Drawable { return _cloudsprites[i]; } virtual void drawImplementation(osg::RenderInfo& renderInfo) const; - virtual osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) - computeBound() -#else - computeBoundingBox() -#endif - const + virtual osg::BoundingBox computeBoundingBox() const { return _bbox; } diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index 08649e1e..dbbcb6b7 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -29,7 +29,6 @@ #include -#include #include #include #include diff --git a/simgear/scene/sky/moon.cxx b/simgear/scene/sky/moon.cxx index d9a1e39c..363c1335 100644 --- a/simgear/scene/sky/moon.cxx +++ b/simgear/scene/sky/moon.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/simgear/scene/tgdb/ReaderWriterSPT.cxx b/simgear/scene/tgdb/ReaderWriterSPT.cxx index 638ce476..83f29751 100644 --- a/simgear/scene/tgdb/ReaderWriterSPT.cxx +++ b/simgear/scene/tgdb/ReaderWriterSPT.cxx @@ -209,11 +209,7 @@ ReaderWriterSPT::readObject(const std::string& fileName, const osgDB::Options* o imageFileName = osgDB::concatPaths(imageFileName, "Globe"); imageFileName = osgDB::concatPaths(imageFileName, "world.topo.bathy.200407.3x4096x2048.png"); } -#if OSG_VERSION_LESS_THAN(3,4,0) - if (osg::Image* image = osgDB::readImageFile(imageFileName, options)) { -#else if (osg::Image* image = osgDB::readRefImageFile(imageFileName, options)) { -#endif osg::Texture2D* texture = new osg::Texture2D; texture->setImage(image); texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); @@ -261,11 +257,7 @@ ReaderWriterSPT::createTree(const BucketBox& bucketBox, const LocalOptions& opti if (bucketBox.getIsBucketSize()) { std::string fileName; fileName = bucketBox.getBucket().gen_index_str() + std::string(".stg"); -#if OSG_VERSION_LESS_THAN(3,4,0) - return osgDB::readNodeFile(fileName, options._options); -#else return osgDB::readRefNodeFile(fileName, options._options); -#endif } else if (!topLevel && options.isPageLevel(bucketBox.getStartLevel())) { return createPagedLOD(bucketBox, options); } else { @@ -323,11 +315,8 @@ ReaderWriterSPT::createPagedLOD(const BucketBox& bucketBox, const LocalOptions& std::string fileName = osgDB::findDataFile(lodPath + extensions[i], options._options); if (fileName.empty()) continue; -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::ref_ptr node = osgDB::readNodeFile(fileName, options._options); -#else + osg::ref_ptr node = osgDB::readRefNodeFile(fileName, options._options); -#endif if (!node.valid()) continue; pagedLOD->addChild(node.get(), range, std::numeric_limits::max()); @@ -425,11 +414,7 @@ ReaderWriterSPT::getLowLODStateSet(const LocalOptions& options) const localOptions = static_cast(options._options->clone(osg::CopyOp())); localOptions->setObjectCacheHint(osgDB::Options::CACHE_ALL); -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::ref_ptr object = osgDB::readObjectFile("state.spt", localOptions.get()); -#else osg::ref_ptr object = osgDB::readRefObjectFile("state.spt", localOptions.get()); -#endif if (!dynamic_cast(object.get())) return 0; diff --git a/simgear/scene/tgdb/ReaderWriterSTG.cxx b/simgear/scene/tgdb/ReaderWriterSTG.cxx index 9aff6737..332c157a 100644 --- a/simgear/scene/tgdb/ReaderWriterSTG.cxx +++ b/simgear/scene/tgdb/ReaderWriterSTG.cxx @@ -163,11 +163,7 @@ struct ReaderWriterSTG::_ModelBin { proxy->setCenterMode(osg::ProxyNode::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED); node = proxy; } else { -#if OSG_VERSION_LESS_THAN(3,4,0) - node = osgDB::readNodeFile(o._name, o._options.get()); -#else node = osgDB::readRefNodeFile(o._name, o._options.get()); -#endif if (!node.valid()) { SG_LOG(SG_TERRAIN, SG_ALERT, o._errorLocation << ": Failed to load " << o._token << " '" << o._name << "'"); @@ -582,11 +578,8 @@ struct ReaderWriterSTG::_ModelBin { if (_foundBase) { for (auto stgObject : _objectList) { osg::ref_ptr node; -#if OSG_VERSION_LESS_THAN(3,4,0) - node = osgDB::readNodeFile(stgObject._name, stgObject._options.get()); -#else node = osgDB::readRefNodeFile(stgObject._name, stgObject._options.get()); -#endif + if (!node.valid()) { SG_LOG(SG_TERRAIN, SG_ALERT, stgObject._errorLocation << ": Failed to load " << stgObject._token << " '" << stgObject._name << "'"); diff --git a/simgear/scene/tgdb/SGVasiDrawable.cxx b/simgear/scene/tgdb/SGVasiDrawable.cxx index d66474fe..70795d54 100644 --- a/simgear/scene/tgdb/SGVasiDrawable.cxx +++ b/simgear/scene/tgdb/SGVasiDrawable.cxx @@ -103,13 +103,7 @@ SGVasiDrawable::drawImplementation(osg::RenderInfo& renderInfo) const draw(eyePoint, _lights[i]); } -osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) -SGVasiDrawable::computeBound() -#else -SGVasiDrawable::computeBoundingBox() -#endif -const +osg::BoundingBox SGVasiDrawable::computeBoundingBox() const { osg::BoundingBox bb; for (unsigned i = 0; i < _lights.size(); ++i) diff --git a/simgear/scene/tgdb/SGVasiDrawable.hxx b/simgear/scene/tgdb/SGVasiDrawable.hxx index e4b0479a..67d50e61 100644 --- a/simgear/scene/tgdb/SGVasiDrawable.hxx +++ b/simgear/scene/tgdb/SGVasiDrawable.hxx @@ -50,13 +50,7 @@ public: const SGVec3f& up); virtual void drawImplementation(osg::RenderInfo& renderInfo) const; - virtual osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) - computeBound() -#else - computeBoundingBox() -#endif - const; + virtual osg::BoundingBox computeBoundingBox() const; private: SGVec4f getColor(float angleDeg) const; diff --git a/simgear/scene/tgdb/ShaderGeometry.cxx b/simgear/scene/tgdb/ShaderGeometry.cxx index cef28786..730fe571 100644 --- a/simgear/scene/tgdb/ShaderGeometry.cxx +++ b/simgear/scene/tgdb/ShaderGeometry.cxx @@ -47,11 +47,8 @@ void ShaderGeometry::addObject(const Vec3& position, float scale, void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const { State& state = *renderInfo.getState(); -#if OSG_VERSION_LESS_THAN(3,3,4) - const Extensions* extensions = getExtensions(state.getContextID(), true); -#else const GLExtensions* extensions = GLExtensions::Get(state.getContextID(), true); -#endif + Vec4Array::const_iterator citer = _posScaleArray->begin(); Vec4Array::const_iterator cend = _posScaleArray->end(); FloatArray::const_iterator viter = _vertexAttribArray->begin(); @@ -64,20 +61,9 @@ void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const } } -BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) -ShaderGeometry::computeBound() -#else -ShaderGeometry::computeBoundingBox() -#endif -const +BoundingBox ShaderGeometry::computeBoundingBox() const { - const BoundingBox& geom_box = -#if OSG_VERSION_LESS_THAN(3,3,2) - _geometry->getBound(); -#else - _geometry->getBoundingBox(); -#endif + const BoundingBox& geom_box = _geometry->getBoundingBox(); BoundingBox bb; const Vec4Array* posScales = _posScaleArray.get(); diff --git a/simgear/scene/tgdb/ShaderGeometry.hxx b/simgear/scene/tgdb/ShaderGeometry.hxx index 7a711f22..9324aa29 100644 --- a/simgear/scene/tgdb/ShaderGeometry.hxx +++ b/simgear/scene/tgdb/ShaderGeometry.hxx @@ -60,13 +60,7 @@ class ShaderGeometry : public osg::Drawable virtual void drawImplementation(osg::RenderInfo& renderInfo) const; - virtual osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) - computeBound() -#else - computeBoundingBox() -#endif - const; + virtual osg::BoundingBox computeBoundingBox() const; void setGeometry(osg::Geometry* geometry) { diff --git a/simgear/scene/util/SGEnlargeBoundingBox.cxx b/simgear/scene/util/SGEnlargeBoundingBox.cxx index 5ff19855..d9161299 100644 --- a/simgear/scene/util/SGEnlargeBoundingBox.cxx +++ b/simgear/scene/util/SGEnlargeBoundingBox.cxx @@ -43,12 +43,7 @@ SGEnlargeBoundingBox::SGEnlargeBoundingBox(const SGEnlargeBoundingBox& cb, osg::BoundingBox SGEnlargeBoundingBox::computeBound(const osg::Drawable& drawable) const { - osg::BoundingBox bound = -#if OSG_VERSION_LESS_THAN(3,3,2) - drawable.computeBound(); -#else - drawable.computeBoundingBox(); -#endif + osg::BoundingBox bound = drawable.computeBoundingBox(); if (!bound.valid()) return bound; diff --git a/simgear/scene/util/SGEnlargeBoundingBox.hxx b/simgear/scene/util/SGEnlargeBoundingBox.hxx index b5113866..c3dd75dc 100644 --- a/simgear/scene/util/SGEnlargeBoundingBox.hxx +++ b/simgear/scene/util/SGEnlargeBoundingBox.hxx @@ -32,7 +32,7 @@ public: SGEnlargeBoundingBox(float offset = 0); SGEnlargeBoundingBox(const SGEnlargeBoundingBox& cb, const osg::CopyOp&); META_Object(osg, SGEnlargeBoundingBox); - virtual osg::BoundingBox computeBound(const osg::Drawable& drawable) const; + osg::BoundingBox computeBound(const osg::Drawable& drawable) const override; private: float _offset; diff --git a/simgear/scene/util/SGSceneFeatures.cxx b/simgear/scene/util/SGSceneFeatures.cxx index 23f4e849..3d0527ab 100644 --- a/simgear/scene/util/SGSceneFeatures.cxx +++ b/simgear/scene/util/SGSceneFeatures.cxx @@ -97,48 +97,22 @@ SGSceneFeatures::applyTextureCompression(osg::Texture* texture) const bool SGSceneFeatures::getHavePointSprites(unsigned contextId) const { -#if OSG_VERSION_LESS_THAN(3,3,4) - return osg::PointSprite::isPointSpriteSupported(contextId); -#else const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true); return ex && ex->isPointSpriteSupported; -#endif } bool SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const { -#if OSG_VERSION_LESS_THAN(3,3,4) - const osg::FragmentProgram::Extensions* fpe; - fpe = osg::FragmentProgram::getExtensions(contextId, true); - if (!fpe) - return false; - if (!fpe->isFragmentProgramSupported()) - return false; - - return true; -#else const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true); return ex && ex->isFragmentProgramSupported; -#endif } bool SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const { -#if OSG_VERSION_LESS_THAN(3,3,4) - const osg::VertexProgram::Extensions* vpe; - vpe = osg::VertexProgram::getExtensions(contextId, true); - if (!vpe) - return false; - if (!vpe->isVertexProgramSupported()) - return false; - - return true; -#else const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true); return ex && ex->isVertexProgramSupported; -#endif } bool @@ -152,16 +126,6 @@ SGSceneFeatures::getHaveShaderPrograms(unsigned contextId) const bool SGSceneFeatures::getHavePointParameters(unsigned contextId) const { -#if OSG_VERSION_LESS_THAN(3,3,4) - const osg::Point::Extensions* pe; - pe = osg::Point::getExtensions(contextId, true); - if (!pe) - return false; - if (!pe->isPointParametersSupported()) - return false; - return true; -#else const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true); return ex && ex->isPointParametersSupported; -#endif } diff --git a/simgear/structure/CMakeLists.txt b/simgear/structure/CMakeLists.txt index fb13114d..130f1e5e 100644 --- a/simgear/structure/CMakeLists.txt +++ b/simgear/structure/CMakeLists.txt @@ -3,7 +3,6 @@ include (SimGearComponent) set(HEADERS OSGUtils.hxx - OSGVersion.hxx SGAtomic.hxx SGBinding.hxx SGExpression.hxx diff --git a/simgear/structure/OSGVersion.hxx b/simgear/structure/OSGVersion.hxx deleted file mode 100644 index b17f77c5..00000000 --- a/simgear/structure/OSGVersion.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// OSGVersion.hxx - transform OpenSceneGraph version to something useful -// -// Copyright (C) 2008 Tim Moore timoore@redhat.com -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -// Boston, MA 02110-1301, USA. - -#ifndef SIMGEAR_OSGVERSION_HXX -#define SIMGEAR_OSGVERSION_HXX 1 -#include -#define SG_OSG_VERSION \ - ((OPENSCENEGRAPH_MAJOR_VERSION*10000)\ - + (OPENSCENEGRAPH_MINOR_VERSION*1000) + OPENSCENEGRAPH_PATCH_VERSION) - -#define SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH) \ - ((OPENSCENEGRAPH_MAJOR_VERSION > (MAJOR)) || \ - (OPENSCENEGRAPH_MAJOR_VERSION == (MAJOR) && \ - (OPENSCENEGRAPH_MINOR_VERSION > (MINOR) || \ - (OPENSCENEGRAPH_MINOR_VERSION == (MINOR) && \ - OPENSCENEGRAPH_PATCH_VERSION >= (PATCH))))) - -#define SG_OSG_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) \ - ((OPENSCENEGRAPH_MAJOR_VERSION > (MAJOR)) || \ - (OPENSCENEGRAPH_MAJOR_VERSION == (MAJOR) && \ - (OPENSCENEGRAPH_MINOR_VERSION > (MINOR) || \ - (OPENSCENEGRAPH_MINOR_VERSION == (MINOR) && \ - OPENSCENEGRAPH_PATCH_VERSION > (PATCH))))) - -#define SG_OSG_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) \ - (!SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH)) - -#define SG_OSG_VERSION_LESS_EQUAL(MAJOR, MINOR, PATCH) \ - (!SG_OSG_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH)) - -#define SG_OSG_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) \ - SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH) - -#endif