Introduced CMake option OSG_PROVIDE_READFILE option that defaults to ON, but when switched to OFF disables the building of the osgDB::read*File() methods,

forcing users to use osgDB::readRef*File() methods.  The later is preferable as it closes a potential threading bug when using paging databases in conjunction
with the osgDB::Registry Object Cache.  This threading bug occurs when one thread gets an object from the Cache via an osgDB::read*File() call where only
a pointer to the object is passed back, so taking a reference to the object is delayed till it gets reassigned to a ref_ptr<>, but at the same time another
thread calls a flush of the Object Cache deleting this object as it's referenceCount is now zero.  Using osgDB::readREf*File() makes sure the a ref_ptr<> is
passed back and the referenceCount never goes to zero.

To ensure the OSG builds when OSG_PROVIDE_READFILE is to OFF the many cases of osgDB::read*File() usage had to be replaced with a ref_ptr<> osgDB::readRef*File()
usage.  The avoid this change causing lots of other client code to be rewritten to handle the use of ref_ptr<> in place of C pointer I introduced a serious of
templte methods in various class to adapt ref_ptr<> to the underly C pointer to be passed to old OSG API's, example of this is found in include/osg/Group:

    bool addChild(Node* child); // old method which can only be used with a Node*

    tempalte<class T> bool addChild(const osg::ref_ptr<T>& child) { return addChild(child.get()); } // adapter template method

These changes together cover 149 modified files, so it's a large submission. This extent of changes are warrent to make use of the Object Cache
and multi-threaded loaded more robust.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.4@15165 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-10-22 14:14:53 +00:00
parent 74f1838960
commit 6a67be2e32
281 changed files with 2443 additions and 2050 deletions

View File

@@ -1088,7 +1088,7 @@ static osgDB::ReaderWriter::Options* createOptions()
static osg::Image* loadImage(const char *fileName, osgDB::ReaderWriter::Options *options)
{
osg::ref_ptr<osg::Image> osgImage = osgDB::readImageFile(fileName, options);
osg::ref_ptr<osg::Image> osgImage = osgDB::readRefImageFile(fileName, options);
if (!osgImage)
{

View File

@@ -220,9 +220,9 @@ protected:
material->setDiffuse (osg::Material::FRONT_AND_BACK,osg::Vec4(diffuse,alpha));
material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(specular,alpha));
material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(emissive,alpha));
if (shininess>=0.0f)
{
{
material->setShininess(osg::Material::FRONT_AND_BACK,shininess);
}
else
@@ -276,7 +276,7 @@ protected:
material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(emissive,alpha));
if (shininess>=0.0f)
{
{
material->setShininess(osg::Material::FRONT_AND_BACK,shininess);
}
else
@@ -346,7 +346,7 @@ protected:
// Read attribute file
std::string attrname = filename + ".attr";
osg::ref_ptr<AttrData> attr = dynamic_cast<AttrData*>(osgDB::readObjectFile(attrname,document.getOptions()));
osg::ref_ptr<AttrData> attr = osgDB::readRefFile<AttrData>(attrname,document.getOptions());
if (attr.valid())
{
// Wrap mode
@@ -899,7 +899,7 @@ protected:
std::string vertexProgramFilePath = osgDB::findDataFile(vertexProgramFilename,document.getOptions());
if (!vertexProgramFilePath.empty())
{
osg::Shader* vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, vertexProgramFilePath);
osg::ref_ptr<osg::Shader> vertexShader = osgDB::readRefShaderFile(osg::Shader::VERTEX, vertexProgramFilePath);
if (vertexShader)
program->addShader( vertexShader );
}
@@ -913,7 +913,7 @@ protected:
std::string fragmentProgramFilePath = osgDB::findDataFile(fragmentProgramFilename,document.getOptions());
if (!fragmentProgramFilePath.empty())
{
osg::Shader* fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, fragmentProgramFilePath);
osg::ref_ptr<osg::Shader> fragmentShader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, fragmentProgramFilePath);
if (fragmentShader)
program->addShader( fragmentShader );
}

View File

@@ -12,7 +12,7 @@
*/
//
// OpenFlight<EFBFBD> loader for OpenSceneGraph
// OpenFlight loader for OpenSceneGraph
//
// Copyright (C) 2005-2007 Brede Johansen
//
@@ -174,7 +174,7 @@ public:
std::string filename = node.getFileName(pos);
// read external
osg::ref_ptr<osg::Node> external = osgDB::readNodeFile(filename,_options.get());
osg::ref_ptr<osg::Node> external = osgDB::readRefNodeFile(filename,_options.get());
if (external.valid())
{
if (_cloneExternalReferences)

View File

@@ -518,7 +518,7 @@ ref_ptr<Group> VBSPEntity::createModelGeometry()
ref_ptr<Group> entityGroup;
// Try to load the model
modelNode = osgDB::readNodeFile(entity_model);
modelNode = osgDB::readRefNodeFile(entity_model);
if (modelNode.valid())
{
// Create a group and add the model to it

View File

@@ -1094,7 +1094,7 @@ void VBSPReader::createScene()
// Load the prop's model
propModel = bsp_data->getStaticPropModel(staticProp.prop_type);
propNode = osgDB::readNodeFile(propModel);
propNode = osgDB::readRefNodeFile(propModel);
// If we loaded the prop correctly, add it to the scene
if (propNode.valid())

View File

@@ -62,7 +62,7 @@ FbxMaterialToOsgStateSet::convert(const FbxSurfaceMaterial* pFbxMat)
if (transparentColor[0] < 1.0 || transparentColor[1] < 1.0 || transparentColor[2] < 1.0) {
transparencyColorFactor = transparentColor[0]*0.30 + transparentColor[1]*0.59 + transparentColor[2]*0.11;
useTransparencyColorFactor = true;
}
}
int lNbTex = lOpacityProperty.GetSrcObjectCount<FbxFileTexture>();
for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++)
@@ -187,7 +187,7 @@ FbxMaterialToOsgStateSet::convert(const FbxSurfaceMaterial* pFbxMat)
static_cast<float>(color[1] * factor),
static_cast<float>(color[2] * factor),
1.0f));
// Since Maya and 3D studio Max stores their glossiness values in exponential format (2^(log2(x))
// Since Maya and 3D studio Max stores their glossiness values in exponential format (2^(log2(x))
// We need to linearize to values between 0-100 and then scale to values between 0-128.
// Glossiness values above 100 will result in shininess larger than 128.0 and will be clamped
double shininess = (64.0 * log (pFbxPhong->Shininess.Get())) / (5.0 * log(2.0));
@@ -226,9 +226,9 @@ FbxMaterialToOsgStateSet::fbxTextureToOsgTexture(const FbxFileTexture* fbx)
// Warning: fbx->GetRelativeFileName() is relative TO EXECUTION DIR
// fbx->GetFileName() is as stored initially in the FBX
if ((pImage = osgDB::readImageFile(osgDB::concatPaths(_dir, fbx->GetFileName()), _options)) || // First try "export dir/name"
(pImage = osgDB::readImageFile(fbx->GetFileName(), _options)) || // Then try "name" (if absolute)
(pImage = osgDB::readImageFile(osgDB::concatPaths(_dir, fbx->GetRelativeFileName()), _options))) // Else try "current dir/name"
if ((pImage = osgDB::readRefImageFile(osgDB::concatPaths(_dir, fbx->GetFileName()), _options)) || // First try "export dir/name"
(pImage = osgDB::readRefImageFile(fbx->GetFileName(), _options)) || // Then try "name" (if absolute)
(pImage = osgDB::readRefImageFile(osgDB::concatPaths(_dir, fbx->GetRelativeFileName()), _options))) // Else try "current dir/name"
{
osg::ref_ptr<osg::Texture2D> pOsgTex = new osg::Texture2D;
pOsgTex->setImage(pImage.get());

View File

@@ -133,7 +133,7 @@ public:
return ReadResult::FILE_NOT_HANDLED;
// recursively load the subfile.
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile( realName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( realName, options );
if( !node )
{
// propagate the read failure upwards

View File

@@ -57,7 +57,7 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
const std::string filename = code.substr( pos2 + 1, pos3 - pos2 - 1 );
osg::ref_ptr<osg::Shader> innerShader = osgDB::readShaderFile( shader->getType(), filename, options );
osg::ref_ptr<osg::Shader> innerShader = osgDB::readRefShaderFile( shader->getType(), filename, options );
if ( !innerShader.valid() )
{

View File

@@ -1914,7 +1914,7 @@ osgTerrain::Layer* DataInputStream::readLayer()
else if (layerid==IVEPROXYLAYER)
{
std::string filename = readString();
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename+".gdal");
osg::ref_ptr<osg::Object> object = osgDB::readRefObjectFile(filename+".gdal");
osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(object.get());
osg::ref_ptr<osgTerrain::Locator> locator = readLocator();

View File

@@ -107,7 +107,7 @@ void HeightFieldLayer::read(DataInputStream* in)
if (in->getVersion()>=VERSION_0035)
{
osg::HeightField* hf = new osg::HeightField;
osg::ref_ptr<osg::HeightField> hf = new osg::HeightField;
// Read HeightField's properties
//setColor(in->readVec4());
@@ -128,13 +128,13 @@ void HeightFieldLayer::read(DataInputStream* in)
in->readPackedFloatArray(hf->getFloatArray());
}
setHeightField(hf);
setHeightField(hf.get());
}
else
{
osg::Shape* shape = in->readShape();
setHeightField(dynamic_cast<osg::HeightField*>(shape));
osg::ref_ptr<osg::Shape> shape = in->readShape();
setHeightField(dynamic_cast<osg::HeightField*>(shape.get()));
}
}
@@ -143,7 +143,8 @@ void HeightFieldLayer::read(DataInputStream* in)
std::string filename = in->readString();
setFileName(filename);
setHeightField(osgDB::readHeightFieldFile(filename,in->getOptions()));
osg::ref_ptr<osg::HeightField> hf = osgDB::readRefHeightFieldFile(filename,in->getOptions());
if (hf) setHeightField(hf.get());
}
}

View File

@@ -190,8 +190,7 @@ osgTerrain::Layer* LayerHelper::readLayer(DataInputStream* in)
else if (id==IVEPROXYLAYER)
{
std::string filename = in->readString();
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename+".gdal");
osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(object.get());
osg::ref_ptr<osgTerrain::ProxyLayer> proxyLayer = osgDB::readRefFile<osgTerrain::ProxyLayer>(filename+".gdal");
osg::ref_ptr<osgTerrain::Locator> locator = readLocator(in);
unsigned int minLevel = in->readUInt();
@@ -205,7 +204,7 @@ osgTerrain::Layer* LayerHelper::readLayer(DataInputStream* in)
proxyLayer->setMaxLevel(maxLevel);
}
return proxyLayer;
return proxyLayer.release();
}
return new osgTerrain::ImageLayer;

View File

@@ -205,7 +205,7 @@ void ProxyNode::read(DataInputStream* in)
{
osgDB::FilePathList& fpl = ((osgDB::ReaderWriter::Options*)in->getOptions())->getDatabasePathList();
fpl.push_front( fpl.empty() ? osgDB::getFilePath(getFileName(i)) : fpl.front()+'/'+ osgDB::getFilePath(getFileName(i)));
osg::Node *node = osgDB::readNodeFile(getFileName(i), in->getOptions());
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(getFileName(i), in->getOptions());
fpl.pop_front();
if(node)

View File

@@ -1767,7 +1767,7 @@ static int readObjectFile(lua_State * _lua)
if (n==1 && lua_type(_lua, 1)==LUA_TSTRING)
{
std::string filename = lua_tostring(_lua, 1);
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename);
osg::ref_ptr<osg::Object> object = osgDB::readRefObjectFile(filename);
if (object.valid())
{
lse->pushObject(object.get());
@@ -1785,7 +1785,7 @@ static int readImageFile(lua_State * _lua)
if (n==1 && lua_type(_lua, 1)==LUA_TSTRING)
{
std::string filename = lua_tostring(_lua, 1);
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename);
if (image.valid())
{
lse->pushObject(image.get());
@@ -1803,7 +1803,7 @@ static int readNodeFile(lua_State * _lua)
if (n==1 && lua_type(_lua, 1)==LUA_TSTRING)
{
std::string filename = lua_tostring(_lua, 1);
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filename);
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(filename);
if (node.valid())
{
lse->pushObject(node.get());

View File

@@ -107,7 +107,7 @@ osg::Group *SceneLoader::load(const std::string &filename, const osgDB::ReaderWr
std::getline(ifs, field);
version_ = atoi(field.c_str());
std::string identifier;
while (ifs >> identifier) {
@@ -256,7 +256,7 @@ bool SceneLoader::parse_block(const std::string &name, const std::string &data)
OSG_NOTICE << "Loading object \"" << filename << "\"" << std::endl;
objnode = dynamic_cast<osg::Group *>(osgDB::readNodeFile(filename));
objnode = osgDB::readRefFile<osg::Group>(filename);
if (!objnode.valid()) return false;
objects_[filename] = objnode;

View File

@@ -77,7 +77,7 @@ class NormalsReader: public osgDB::ReaderWriter
std::string nodeName = osgDB::getNameLessExtension( fileName );
if( !nodeName.empty() )
{
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile( nodeName );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( nodeName );
if( node.valid() )
{
osg::ref_ptr<osg::Group> group = new osg::Group;

View File

@@ -201,7 +201,7 @@ public:
}
is.decompress(); CATCH_EXCEPTION(is);
osg::Object* obj = is.readObject(); CATCH_EXCEPTION(is);
osg::ref_ptr<osg::Object> obj = is.readObject(); CATCH_EXCEPTION(is);
return obj;
}
@@ -231,7 +231,7 @@ public:
}
is.decompress(); CATCH_EXCEPTION(is);
osg::Image* image = is.readImage(); CATCH_EXCEPTION(is);
osg::ref_ptr<osg::Image> image = is.readImage(); CATCH_EXCEPTION(is);
return image;
}
@@ -262,7 +262,7 @@ public:
}
is.decompress(); CATCH_EXCEPTION(is);
osg::Node* node = dynamic_cast<osg::Node*>(is.readObject()); CATCH_EXCEPTION(is);
osg::ref_ptr<osg::Node> node = is.readObjectOfType<osg::Node>(); CATCH_EXCEPTION(is);
if ( !node ) return ReadResult::FILE_NOT_HANDLED;
return node;
}

View File

@@ -231,7 +231,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterJSON::readNode(const std::string& fi
fileName = osgDB::findDataFile( fileName, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
osg::Node *node = osgDB::readNodeFile( fileName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( fileName, options );
if (!node)
return ReadResult::FILE_NOT_HANDLED;

View File

@@ -656,7 +656,7 @@ JSONObject* WriteVisitor::createJSONPagedLOD(osg::PagedLOD *plod)
ss << i;
std::string str = ss.str();
// We need to convert first from osg format to osgjs format.
osg::ref_ptr<osg::Node> n = osgDB::readNodeFile(plod->getFileName(i)+".gles");
osg::ref_ptr<osg::Node> n = osgDB::readRefNodeFile(plod->getFileName(i)+".gles");
if (n)
{
std::string filename(osgDB::getStrippedName(plod->getFileName(i))+".osgjs");

View File

@@ -91,7 +91,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter
std::string file_ext = osgDB::getLowerCaseFileExtension(*itr);
if (osgDB::equalCaseInsensitive(file_ext,"osg"))
{
osg::Node *node = osgDB::readNodeFile( *itr, local_options.get() );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( *itr, local_options.get() );
grp->addChild( node );
}
}

View File

@@ -1370,7 +1370,7 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
std::string vs;
if (getProperty(cur, "vs", vs) || getProperty(cur, "VolumeSettings", vs))
{
volumeData.volumeSettings = osgDB::readFile<osgVolume::VolumeSettings>(vs);
volumeData.volumeSettings = osgDB::readRefFile<osgVolume::VolumeSettings>(vs);
if (volumeData.volumeSettings.valid())
{
OSG_NOTICE<<"VolumeSetting read "<<vs<<" "<<volumeData.volumeSettings.get()<<std::endl;
@@ -1438,12 +1438,12 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
std::string transferFunctionFile;
if (getTrimmedProperty(cur, "tf", transferFunctionFile))
{
volumeData.transferFunction = osgDB::readFile<osg::TransferFunction1D>(transferFunctionFile);
volumeData.transferFunction = osgDB::readRefFile<osg::TransferFunction1D>(transferFunctionFile);
}
if (getTrimmedProperty(cur, "tf-255", transferFunctionFile))
{
volumeData.transferFunction = osgDB::readFile<osg::TransferFunction1D>(transferFunctionFile);
volumeData.transferFunction = osgDB::readRefFile<osg::TransferFunction1D>(transferFunctionFile);
}
if (getProperty(cur, "options", volumeData.options)) {}
@@ -2567,7 +2567,7 @@ void ReaderWriterP3DXML::parseRunScriptFile(osgPresentation::SlideShowConstructo
std::string function = "";
getProperty(cur, "function", function);
osg::ref_ptr<osg::Script> script = osgDB::readFile<osg::Script>(cur->getTrimmedContents());
osg::ref_ptr<osg::Script> script = osgDB::readRefFile<osg::Script>(cur->getTrimmedContents());
if (script.valid())
{
osg::ScriptEngine* se = constructor.getOrCreateScriptEngine(script->getLanguage());

View File

@@ -114,8 +114,7 @@ class ReaderWriterRevisions : public osgDB::ReaderWriter
{
std::string complete_path = osgDB::concatPaths(revisions_path, filename);
OSG_INFO<<" complete_path="<<complete_path<<std::endl;
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(complete_path, options);
fileList = dynamic_cast<osgDB::FileList*>(object.get());
fileList = osgDB::readRefFile<osgDB::FileList>(complete_path, options);
}
if (!fileList)

View File

@@ -139,7 +139,7 @@ public:
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( subFileName, options );
if( !node )
{
// propagate the read failure upwards
@@ -147,7 +147,7 @@ public:
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
osg::ref_ptr<osg::MatrixTransform> xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::rotate(
osg::DegreesToRadians( rx ), osg::Vec3( 1, 0, 0 ),

View File

@@ -152,7 +152,7 @@ public:
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( subFileName, options );
if( !node )
{
// propagate the read failure upwards
@@ -160,7 +160,7 @@ public:
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
osg::ref_ptr<osg::MatrixTransform> xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::scale( sx, sy, sz ) );
xform->addChild( node );

View File

@@ -121,7 +121,7 @@ public:
if (!technique) technique = new osgShadow::ShadowVolume;
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( subFileName, options );
if( !node )
{
// propagate the read failure upwards
@@ -130,7 +130,7 @@ public:
}
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
shadowedScene->setShadowTechnique(technique.get());
shadowedScene->setShadowTechnique(technique);
shadowedScene->addChild( node );
return shadowedScene;
}

View File

@@ -83,7 +83,7 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter
if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
{
osg::Node* node = osgDB::readNodeFile(fr[1].getStr());
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(fr[1].getStr());
if (node) group->addChild(node);
@@ -94,7 +94,7 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter
osg::ref_ptr<osg::Node> node = fr.readNode();
if (node.valid())
{
group->addChild(node.get());
group->addChild(node);
itrAdvanced = true;
}
@@ -105,7 +105,7 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter
}
}
if (group->getNumChildren()>0) return group.release();
if (group->getNumChildren()>0) return group;
else return 0;
}

View File

@@ -113,8 +113,8 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
*itr!=std::string(".") &&
*itr!=std::string(".."))
{
osg::Node *node = osgDB::readNodeFile(*itr, local_options.get());
grp->addChild( node );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(*itr, local_options.get());
if (node) grp->addChild( node );
}
}
@@ -136,7 +136,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter
return ReadResult::FILE_NOT_HANDLED;
}
return grp.get();
return grp;
}

View File

@@ -139,7 +139,7 @@ public:
}
// recursively load the subfile.
osg::Node *node = osgDB::readNodeFile( subFileName, options );
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile( subFileName, options );
if( !node )
{
// propagate the read failure upwards
@@ -147,7 +147,7 @@ public:
return ReadResult::FILE_NOT_HANDLED;
}
osg::MatrixTransform *xform = new osg::MatrixTransform;
osg::ref_ptr<osg::MatrixTransform> xform = new osg::MatrixTransform;
xform->setDataVariance( osg::Object::STATIC );
xform->setMatrix( osg::Matrix::translate( tx, ty, tz ) );
xform->addChild( node );

View File

@@ -169,7 +169,7 @@ struct AssignDirectionColour
osg::ref_ptr<osg::StateSet> stateset = geometry->getOrCreateStateSet();
osg::ref_ptr<osg::Program> program = new osg::Program;
osg::ref_ptr<osg::Shader> vertexShader = osgDB::readShaderFile(osg::Shader::VERTEX, vertexShaderFile);
osg::ref_ptr<osg::Shader> vertexShader = osgDB::readRefShaderFile(osg::Shader::VERTEX, vertexShaderFile);
if (!vertexShader)
{
vertexShader = new osg::Shader(osg::Shader::VERTEX, vert_shader_str);

View File

@@ -434,7 +434,7 @@ bool TXPArchive::loadModel(int ix)
mod->GetName(name,1023);
// Load the model. It's probably not TerraPage
osg::Node *osg_model = osgDB::readNodeFile( name );
osg::ref_ptr<osg::Node> osg_model = osgDB::readRefNodeFile( name );
if ( !osg_model )
{
OSG_WARN << "TrPageArchive::LoadModels() error: "
@@ -642,9 +642,8 @@ bool TXPArchive::loadTextStyles()
continue;
std::string fontfilename = fontmap[*fontName];
if ( !fontfilename.length() )
fontfilename = "arial.ttf";
osg::ref_ptr< osgText::Font > font = osgText::readFontFile(fontfilename);
if ( !fontfilename.length() ) fontfilename = "arial.ttf";
osg::ref_ptr< osgText::Font > font = osgText::readRefFontFile(fontfilename);
_fonts[itr->first] = font;

View File

@@ -845,7 +845,7 @@ void ToVRML::findTextureName(osg::Texture2D* tex, std::string& name, bool& alrea
std::string::size_type pos = nameInput.find_last_of(".");
std::string ext = nameInput.substr(pos, nameInput.length() - pos);
osg::ref_ptr < osg::Image > imgIn = osgDB::readImageFile(nameInput);
osg::ref_ptr < osg::Image > imgIn = osgDB::readRefImageFile(nameInput);
if (!imgIn.valid()) {
osg::notify(osg::ALWAYS) << "WARNING: couldn't read texture named: -" << nameOri << "- use default one instead -" << _defaultImage->getFileName() << "-" << std::endl;
tex->setImage(_defaultImage.get());