Use osgDB::read*File instead of dereferencing the osgDB Registry instance.
This commit is contained in:
parent
f61fe80f60
commit
ff1c035d42
@ -32,6 +32,7 @@
|
|||||||
#include <osg/TextureRectangle>
|
#include <osg/TextureRectangle>
|
||||||
#include <osg/TextureCubeMap>
|
#include <osg/TextureCubeMap>
|
||||||
#include <osgDB/FileUtils>
|
#include <osgDB/FileUtils>
|
||||||
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
@ -240,8 +241,8 @@ void setAttrs(const TexTuple& attrs, Texture* tex,
|
|||||||
if (imageName.empty()) {
|
if (imageName.empty()) {
|
||||||
throw BuilderException("no image file");
|
throw BuilderException("no image file");
|
||||||
} else {
|
} else {
|
||||||
osgDB::ReaderWriter::ReadResult result
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
= osgDB::Registry::instance()->readImage(imageName, options);
|
result = osgDB::readImageFile(imageName, options);
|
||||||
if (result.success()) {
|
if (result.success()) {
|
||||||
osg::ref_ptr<osg::Image> image = result.getImage();
|
osg::ref_ptr<osg::Image> image = result.getImage();
|
||||||
image = computeMipmap( image.get(), attrs.get<7>() );
|
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_T, osg::Texture::CLAMP_TO_EDGE);
|
||||||
cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
|
cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
|
||||||
|
|
||||||
osgDB::ReaderWriter::ReadResult result =
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
osgDB::Registry::instance()->readImage(_tuple.get<0>(), options);
|
result = osgDB::readImageFile(_tuple.get<0>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image);
|
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()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image);
|
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()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image);
|
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()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image);
|
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()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image);
|
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()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
|
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
|
||||||
@ -560,8 +561,8 @@ Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
|
|||||||
if (itr != _crossmaps.end())
|
if (itr != _crossmaps.end())
|
||||||
return itr->second.get();
|
return itr->second.get();
|
||||||
|
|
||||||
osgDB::ReaderWriter::ReadResult result =
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
osgDB::Registry::instance()->readImage(texname, options);
|
result = osgDB::readImageFile(texname, options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
|
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
|
#include <osgDB/ReadFile>
|
||||||
#include <osgDB/WriteFile>
|
#include <osgDB/WriteFile>
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
#include <osg/Switch>
|
#include <osg/Switch>
|
||||||
@ -280,9 +281,8 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
texturepath = texturepath.dir();
|
texturepath = texturepath.dir();
|
||||||
|
|
||||||
options->setDatabasePath(texturepath.str());
|
options->setDatabasePath(texturepath.str());
|
||||||
osgDB::ReaderWriter::ReadResult modelResult
|
osgDB::ReaderWriter::ReadResult modelResult;
|
||||||
= osgDB::Registry::instance()->readNode(modelpath.str(),
|
modelResult = osgDB::readNodeFile(modelpath.str(), options.get());
|
||||||
options.get());
|
|
||||||
if (!modelResult.validNode())
|
if (!modelResult.validNode())
|
||||||
throw sg_io_exception("Failed to load 3D model:" + modelResult.message(),
|
throw sg_io_exception("Failed to load 3D model:" + modelResult.message(),
|
||||||
modelpath.str());
|
modelpath.str());
|
||||||
|
Loading…
Reference in New Issue
Block a user