From ff1c035d428480ced6f12e1fba82b83f4803d987 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 12 Nov 2011 19:44:56 +0100 Subject: [PATCH] Use osgDB::read*File instead of dereferencing the osgDB Registry instance. --- simgear/scene/material/TextureBuilder.cxx | 23 ++++++++++++----------- simgear/scene/model/SGReaderWriterXML.cxx | 6 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/simgear/scene/material/TextureBuilder.cxx b/simgear/scene/material/TextureBuilder.cxx index 69630b31..0c141c47 100644 --- a/simgear/scene/material/TextureBuilder.cxx +++ b/simgear/scene/material/TextureBuilder.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -240,8 +241,8 @@ void setAttrs(const TexTuple& attrs, Texture* tex, if (imageName.empty()) { throw BuilderException("no image file"); } else { - osgDB::ReaderWriter::ReadResult result - = osgDB::Registry::instance()->readImage(imageName, options); + osgDB::ReaderWriter::ReadResult result; + result = osgDB::readImageFile(imageName, options); if (result.success()) { osg::ref_ptr image = result.getImage(); image = computeMipmap( image.get(), attrs.get<7>() ); @@ -511,33 +512,33 @@ Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props, cubeTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture::CLAMP_TO_EDGE); cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE); - osgDB::ReaderWriter::ReadResult result = - osgDB::Registry::instance()->readImage(_tuple.get<0>(), options); + osgDB::ReaderWriter::ReadResult result; + result = osgDB::readImageFile(_tuple.get<0>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image); } - result = osgDB::Registry::instance()->readImage(_tuple.get<1>(), options); + result = osgDB::readImageFile(_tuple.get<1>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image); } - result = osgDB::Registry::instance()->readImage(_tuple.get<2>(), options); + result = osgDB::readImageFile(_tuple.get<2>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image); } - result = osgDB::Registry::instance()->readImage(_tuple.get<3>(), options); + result = osgDB::readImageFile(_tuple.get<3>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image); } - result = osgDB::Registry::instance()->readImage(_tuple.get<4>(), options); + result = osgDB::readImageFile(_tuple.get<4>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image); } - result = osgDB::Registry::instance()->readImage(_tuple.get<5>(), options); + result = osgDB::readImageFile(_tuple.get<5>(), options); if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image); @@ -560,8 +561,8 @@ Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props, if (itr != _crossmaps.end()) return itr->second.get(); - osgDB::ReaderWriter::ReadResult result = - osgDB::Registry::instance()->readImage(texname, options); + osgDB::ReaderWriter::ReadResult result; + result = osgDB::readImageFile(texname, options); if(result.success()) { osg::Image* image = result.getImage(); image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones diff --git a/simgear/scene/model/SGReaderWriterXML.cxx b/simgear/scene/model/SGReaderWriterXML.cxx index 81ccd85a..2fafbcfa 100644 --- a/simgear/scene/model/SGReaderWriterXML.cxx +++ b/simgear/scene/model/SGReaderWriterXML.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -280,9 +281,8 @@ sgLoad3DModel_internal(const SGPath& path, texturepath = texturepath.dir(); options->setDatabasePath(texturepath.str()); - osgDB::ReaderWriter::ReadResult modelResult - = osgDB::Registry::instance()->readNode(modelpath.str(), - options.get()); + osgDB::ReaderWriter::ReadResult modelResult; + modelResult = osgDB::readNodeFile(modelpath.str(), options.get()); if (!modelResult.validNode()) throw sg_io_exception("Failed to load 3D model:" + modelResult.message(), modelpath.str());