diff --git a/src/osgPlugins/3ds/ReaderWriter3DS.cpp b/src/osgPlugins/3ds/ReaderWriter3DS.cpp index 9280ae649..96192f4fd 100644 --- a/src/osgPlugins/3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/3ds/ReaderWriter3DS.cpp @@ -715,15 +715,15 @@ osg::Texture2D* ReaderWriter3DS::ReaderObject::createTexture(Lib3dsTextureMap * osg::notify(osg::DEBUG_INFO) << " LIB3DS_IGNORE_ALPHA "<<((texture->flags)&LIB3DS_IGNORE_ALPHA)<< std::endl; osg::notify(osg::DEBUG_INFO) << " LIB3DS_RGB_TINT "<<((texture->flags)&LIB3DS_RGB_TINT)<< std::endl; - osg::Image* osg_image = osgDB::readImageFile(fileName.c_str()); - if (osg_image==NULL) + osg::ref_ptr osg_image = osgDB::readRefImageFile(fileName.c_str()); + if (!osg_image) { osg::notify(osg::NOTICE) << "Warning: Cannot create texture "<name<< std::endl; return NULL; } osg::Texture2D* osg_texture = new osg::Texture2D; - osg_texture->setImage(osg_image); + osg_texture->setImage(osg_image.get()); // does the texture support transparancy? transparancy = ((texture->flags)&LIB3DS_ALPHA_SOURCE)!=0; diff --git a/src/osgPlugins/OpenFlight/PaletteRecords.cpp b/src/osgPlugins/OpenFlight/PaletteRecords.cpp index 52bf13323..1f441a64b 100644 --- a/src/osgPlugins/OpenFlight/PaletteRecords.cpp +++ b/src/osgPlugins/OpenFlight/PaletteRecords.cpp @@ -290,7 +290,7 @@ protected: osg::StateSet* readTexture(const std::string& filename, const Document& document) const { - osg::Image* image = osgDB::readImageFile(filename,document.getOptions()); + osg::ref_ptr image = osgDB::readRefImageFile(filename,document.getOptions()); if (!image) return NULL; // Create stateset to hold texture and attributes. @@ -300,7 +300,7 @@ protected: texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT); texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT); texture->setResizeNonPowerOfTwoHint(true); - texture->setImage(image); + texture->setImage(image.get()); stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); // Read attribute file diff --git a/src/osgPlugins/ac/ac3d.cpp b/src/osgPlugins/ac/ac3d.cpp index cf3b1dc85..c15be683f 100644 --- a/src/osgPlugins/ac/ac3d.cpp +++ b/src/osgPlugins/ac/ac3d.cpp @@ -351,7 +351,7 @@ class TextureData osg::notify(osg::FATAL) << "osgDB ac3d reader: could not find texture \"" << name << "\"" << std::endl; return false; } - mImage = osgDB::readImageFile(absFileName, options); + mImage = osgDB::readRefImageFile(absFileName, options); if (!mImage.valid()) { osg::notify(osg::FATAL) << "osgDB ac3d reader: could not read texture \"" << name << "\"" << std::endl; diff --git a/src/osgPlugins/bsp/Q3BSPReader.cpp b/src/osgPlugins/bsp/Q3BSPReader.cpp index 34dea57d0..f9e9cef12 100644 --- a/src/osgPlugins/bsp/Q3BSPReader.cpp +++ b/src/osgPlugins/bsp/Q3BSPReader.cpp @@ -448,10 +448,10 @@ bool Q3BSPReader::loadTextures( std::string jpgExtendedName(aLoadData.m_loadTextures[i].m_name); jpgExtendedName+=".jpg"; - osg::Image* image = osgDB::readImageFile(tgaExtendedName); + osg::ref_ptr image = osgDB::readRefImageFile(tgaExtendedName); if (!image) { - image = osgDB::readImageFile(jpgExtendedName); + image = osgDB::readRefImageFile(jpgExtendedName); if (!image) { aTextureArray.push_back(NULL); @@ -460,7 +460,7 @@ bool Q3BSPReader::loadTextures( } osg::Texture2D* texture= new osg::Texture2D; - texture->setImage(image); + texture->setImage(image.get()); texture->setDataVariance(osg::Object::DYNAMIC); // protect from being optimized away as static state. texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT); diff --git a/src/osgPlugins/bsp/VBSPReader.cpp b/src/osgPlugins/bsp/VBSPReader.cpp index 843b69757..459612e39 100644 --- a/src/osgPlugins/bsp/VBSPReader.cpp +++ b/src/osgPlugins/bsp/VBSPReader.cpp @@ -559,8 +559,8 @@ ref_ptr VBSPReader::readTextureFile(std::string textureName) { std::string texFile; std::string texPath; - Image * texImage; - Texture * texture; + osg::ref_ptr texImage; + osg::ref_ptr texture; // Find the texture's image file texFile = std::string(textureName) + ".vtf"; @@ -585,7 +585,7 @@ ref_ptr VBSPReader::readTextureFile(std::string textureName) // If we found the file, read it, otherwise bail if (!texPath.empty()) { - texImage = readImageFile(texPath); + texImage = readRefImageFile(texPath); // If we got the image, create the texture attribute if (texImage != NULL) @@ -593,18 +593,15 @@ ref_ptr VBSPReader::readTextureFile(std::string textureName) // Create the texture if (texImage->t() == 1) { - texture = new Texture1D(); - ((Texture1D *)texture)->setImage(texImage); + texture = new Texture1D(texImage.get()); } else if (texImage->r() == 1) { - texture = new Texture2D(); - ((Texture2D *)texture)->setImage(texImage); + texture = new Texture2D(texImage.get()); } else { - texture = new Texture3D(); - ((Texture3D *)texture)->setImage(texImage); + texture = new Texture3D(texImage.get()); } // Set texture attributes diff --git a/src/osgPlugins/dae/daeRMaterials.cpp b/src/osgPlugins/dae/daeRMaterials.cpp index 492595eed..3303ad0a4 100644 --- a/src/osgPlugins/dae/daeRMaterials.cpp +++ b/src/osgPlugins/dae/daeRMaterials.cpp @@ -735,7 +735,7 @@ osg::StateAttribute *daeReader::processTexture( domCommon_color_or_texture_type_ return NULL; } //Got a sampler and a surface and an imaged. Time to create the texture stuff for osg - osg::Image *img = NULL; + osg::ref_ptr img; if ( dImg->getInit_from() != NULL ) { // daeURI uri = dImg->getInit_from()->getValue(); @@ -765,7 +765,7 @@ osg::StateAttribute *daeReader::processTexture( domCommon_color_or_texture_type_ #else const char* filename = path.c_str(); #endif - img = osgDB::readImageFile( filename ); + img = osgDB::readRefImageFile( filename ); osg::notify(osg::INFO)<<" processTexture(..) - readImage("<0) { - ctx=osgDB::readImageFile(fname.c_str(),options); - if (ctx) { + ctx=osgDB::readRefImageFile(fname.c_str(),options); + if (ctx.valid()) { ctx->setFileName(fname); - tx=new Texture2D; - tx->setImage(ctx); + tx=new Texture2D(ctx.get()); tx->setWrap(Texture2D::WRAP_S, Texture2D::REPEAT); tx->setWrap(Texture2D::WRAP_T, Texture2D::REPEAT); } @@ -67,8 +66,8 @@ public: dstate->setTextureAttribute(0, texenv ); } } - if (ctx && tx) { // texture exists - dstate->setTextureAttributeAndModes(0,tx,osg::StateAttribute::ON); + if (ctx.valid() && tx.valid()) { // texture exists + dstate->setTextureAttributeAndModes(0,tx.get(),osg::StateAttribute::ON); } } } @@ -175,8 +174,8 @@ private: std::string fname; // picture file enum atten {NONE, INVERSE_DIST, INVERSE_SQUARE} atyp; float bright,halfIn,halfOut,falloff; // light brightness - Image *ctx; - Texture2D *tx; + osg::ref_ptr ctx; + osg::ref_ptr tx; int _lightnum; StateSet *dstate; // used to represent the dw material in OSG }; diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp index 32ebd43b0..95fde2570 100644 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ b/src/osgPlugins/geo/ReaderWriterGEO.cpp @@ -666,8 +666,8 @@ class ReaderGEO pt->setSize(4); dstate->setAttribute(pt); if (txidx>=0 && (unsigned int)txidxsetTextureAttribute(0, txenvlist[txidx] ); - dstate->setTextureAttributeAndModes(0,txlist[txidx],osg::StateAttribute::ON); + dstate->setTextureAttribute(0, txenvlist[txidx].get() ); + dstate->setTextureAttributeAndModes(0,txlist[txidx].get(),osg::StateAttribute::ON); const Image *txim=txlist[txidx]->getImage(); if (txim) { GLint icm=txim->computeNumComponents(txim->getPixelFormat()); @@ -684,7 +684,7 @@ class ReaderGEO matlist[imat]->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); dstate->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON); } - dstate->setAttribute(matlist[imat]); + dstate->setAttribute(matlist[imat].get()); Vec4 col=matlist[imat]->getAmbient(Material::FRONT); if (col[3]<0.99) { dstate->setMode(GL_BLEND,StateAttribute::ON); @@ -1466,11 +1466,11 @@ class ReaderGEO const geoField *gfd=gr->getField(GEO_DB_TEX_FILE_NAME); const char *name = gfd->getChar(); if (name) { - Texture2D *tx=new Texture2D; - Image *ctx=osgDB::readImageFile(name,options); - if (ctx) { + osg::ref_ptr tx = new Texture2D; + osg::ref_ptr ctx = osgDB::readImageFile(name,options); + if (ctx.valid()) { ctx->setFileName(name); - tx->setImage(ctx); + tx->setImage(ctx.get()); } gfd=gr->getField(GEO_DB_TEX_WRAPS); osg::Texture2D::WrapMode wm=Texture2D::REPEAT; @@ -1486,7 +1486,7 @@ class ReaderGEO wm = (iwrap==GEO_DB_TEX_CLAMP) ? Texture2D::CLAMP : Texture2D::REPEAT; } tx->setWrap(Texture2D::WRAP_T, wm); - txlist.push_back(tx); + txlist.push_back(tx.get()); osg::TexEnv* texenv = new osg::TexEnv; osg::TexEnv::Mode md=osg::TexEnv::MODULATE; gfd=gr->getField(GEO_DB_TEX_ENV); @@ -2014,9 +2014,9 @@ private: osg::ref_ptr theHeader; // an OSG class - has animation vars etc std::vector geotxlist; // list of geo::textures for this model std::vector geomatlist; // list of geo::materials for this model - std::vector txlist; // list of osg::textures for this model - std::vector txenvlist; // list of texture environments for the textures - std::vector matlist; // list of materials for current model + std::vector< osg::ref_ptr > txlist; // list of osg::textures for this model + std::vector< osg::ref_ptr > txenvlist; // list of texture environments for the textures + std::vector< osg::ref_ptr > matlist; // list of materials for current model georecord *cpalrec; // colour palette record }; diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 79dbe38a3..2fbf1080c 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -1128,7 +1128,7 @@ osg::Image* DataInputStream::readImage(std::string filename) // Image is not in list. // Read it from disk, - osg::Image* image = osgDB::readImageFile(filename.c_str(),_options.get()); + osg::ref_ptr image = osgDB::readRefImageFile(filename.c_str(),_options.get()); // add it to the imageList, _imageMap[filename] = image; @@ -1136,7 +1136,7 @@ osg::Image* DataInputStream::readImage(std::string filename) if (_verboseOutput) std::cout<<"read/writeImage() ["< image = osgDB::readRefImageFile( name.c_str() ); + if( image.valid()) + logos[pos].push_back( image.get() ); else osg::notify(osg::WARN)<< "Logos::addLogo image file not found : " << name << ".\n"; } diff --git a/src/osgPlugins/lwo/ReaderWriterLWO.cpp b/src/osgPlugins/lwo/ReaderWriterLWO.cpp index d357fdb51..8354831af 100644 --- a/src/osgPlugins/lwo/ReaderWriterLWO.cpp +++ b/src/osgPlugins/lwo/ReaderWriterLWO.cpp @@ -242,15 +242,15 @@ osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string if (lw_material.ctex.flags && strlen(lw_material.ctex.name)!=0) { osg::notify(osg::INFO) << "ctex " << lw_material.ctex.name << std::endl; - osg::Image* image = osgDB::readImageFile(lw_material.ctex.name); - if (image) + osg::ref_ptr image = osgDB::readRefImageFile(lw_material.ctex.name); + if (image.valid()) { // create state osg::StateSet* stateset = new osg::StateSet; // create texture osg::Texture2D* texture = new osg::Texture2D; - texture->setImage(image); + texture->setImage(image.get()); // texture wrap mode static osg::Texture::WrapMode mode[] = { diff --git a/src/osgPlugins/lwo/Surface.cpp b/src/osgPlugins/lwo/Surface.cpp index 2b0343911..222b3d6d7 100644 --- a/src/osgPlugins/lwo/Surface.cpp +++ b/src/osgPlugins/lwo/Surface.cpp @@ -195,11 +195,14 @@ void Surface::generate_stateset(unsigned int max_tex_units, bool force_arb_compr osg::notify(osg::WARN) << "Warning: lwosg::Surface: maximum number of texture units (" << max_tex_units << ") has been reached, skipping incoming blocks" << std::endl; break; } + + osg::ref_ptr image = osgDB::readRefImageFile(image_file, db_options); + if (!image) break; osg::ref_ptr texture = new osg::Texture2D; if (force_arb_compression) texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION); - texture->setImage(osgDB::readImageFile(image_file, db_options)); + texture->setImage(image.get()); texture->setWrap(osg::Texture::WRAP_S, osg_wrap_mode(block.get_image_map().width_wrap)); texture->setWrap(osg::Texture::WRAP_T, osg_wrap_mode(block.get_image_map().height_wrap)); texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR); diff --git a/src/osgPlugins/lwo/old_Lwo2.cpp b/src/osgPlugins/lwo/old_Lwo2.cpp index af1cfc8af..aadc15ca5 100644 --- a/src/osgPlugins/lwo/old_Lwo2.cpp +++ b/src/osgPlugins/lwo/old_Lwo2.cpp @@ -707,14 +707,14 @@ Lwo2::_generate_statesets_from_surfaces() // check if exist texture image for this surface if (surface->image_index >= 0) { - Image* image = osgDB::readImageFile(_images[surface->image_index]); + osg::ref_ptr image = osgDB::readRefImageFile(_images[surface->image_index]); notify(DEBUG_INFO) << "\tloaded image '" << _images[surface->image_index] << "'" << std::endl; notify(DEBUG_INFO) << "\tresult - " << image << std::endl; - if (image) + if (image.valid()) { // create texture Texture2D* texture = new osg::Texture2D; - texture->setImage(image); + texture->setImage(image.get()); state_set->setTextureAttributeAndModes(0, texture, StateAttribute::ON); // setup texture wrapping diff --git a/src/osgPlugins/md2/ReaderWriterMD2.cpp b/src/osgPlugins/md2/ReaderWriterMD2.cpp index a839ac18f..e8440017e 100644 --- a/src/osgPlugins/md2/ReaderWriterMD2.cpp +++ b/src/osgPlugins/md2/ReaderWriterMD2.cpp @@ -224,14 +224,15 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) #if 0 std::vector skin_textures; - for (int si = 0; si < md2_header->numSkins; si++) { - osg::Image *img; - osg::Texture2D *tex; + for (int si = 0; si < md2_header->numSkins; si++) + { + osg::ref_ptr img; + osg::ref_ptr tex; std::string imgname (md2_skins[si].name); // first try loading the imgname straight - img = osgDB::readImageFile (imgname, options); - if (img) { + img = osgDB::readRefImageFile (imgname, options); + if (img.valid()) { tex = new osg::Texture2D; tex->setImage (img); skin_textures.push_back (tex); @@ -244,18 +245,18 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) { // it's a pcx, so try bmp and tga, since pcx sucks std::string basename = imgname.substr (0, imgname.size() - 3); - img = osgDB::readImageFile (basename + "bmp", options); - if (img) { + img = osgDB::readRefImageFile (basename + "bmp", options); + if (img.valid()) { tex = new osg::Texture2D; - tex->setImage (img); + tex->setImage (img.get()); skin_textures.push_back (tex); continue; } - img = osgDB::readImageFile (basename + "tga", options); - if (img) { + img = osgDB::readRefImageFile (basename + "tga", options); + if (img.valid()) { tex = new osg::Texture2D; - tex->setImage (img); + tex->setImage (img,get()); skin_textures.push_back (tex); continue; } @@ -267,16 +268,16 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) } #else // load the single skin - osg::Image *skin_image = NULL; - osg::Texture2D *skin_texture = NULL; + osg::ref_ptr skin_image; + osg::ref_ptr skin_texture = NULL; if (md2_header->numSkins > 0) { std::string imgname (md2_skins[0].name); do { // first try loading the imgname straight - skin_image = osgDB::readImageFile (imgname, options); - if (skin_image) break; + skin_image = osgDB::readRefImageFile(imgname, options); + if (skin_image.valid()) break; // we failed, so check if it's a PCX image if (imgname.size() > 4 && @@ -284,17 +285,17 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) { // it's a pcx, so try bmp and tga, since pcx sucks std::string basename = imgname.substr (0, imgname.size() - 3); - skin_image = osgDB::readImageFile (basename + "bmp", options); - if (skin_image) break; + skin_image = osgDB::readRefImageFile (basename + "bmp", options); + if (skin_image.valid()) break; - skin_image = osgDB::readImageFile (basename + "tga", options); - if (skin_image) break; + skin_image = osgDB::readRefImageFile (basename + "tga", options); + if (skin_image.valid()) break; } } while (0); - if (skin_image) { + if (skin_image.valid()) { skin_texture = new osg::Texture2D; - skin_texture->setImage (skin_image); + skin_texture->setImage (skin_image.get()); skin_texture->setFilter (osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); } else { // couldn't find the referenced texture skin for this model @@ -407,7 +408,7 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) osg::StateSet *state = new osg::StateSet; if (skin_texture != NULL) { - state->setTextureAttributeAndModes (0, skin_texture, osg::StateAttribute::ON); + state->setTextureAttributeAndModes (0, skin_texture.get(), osg::StateAttribute::ON); } base_switch->setStateSet (state); diff --git a/src/osgPlugins/mdl/MDLReader.cpp b/src/osgPlugins/mdl/MDLReader.cpp index fe876c4bb..45d7afc35 100644 --- a/src/osgPlugins/mdl/MDLReader.cpp +++ b/src/osgPlugins/mdl/MDLReader.cpp @@ -84,10 +84,10 @@ std::string MDLReader::getToken(std::string str, const char * delim, ref_ptr MDLReader::readTextureFile(std::string textureName) { - std::string texFile; - std::string texPath; - Image * texImage; - Texture * texture; + std::string texFile; + std::string texPath; + osg::ref_ptr texImage; + osg::ref_ptr texture; // Find the texture's image file texFile = std::string(textureName) + ".vtf"; @@ -124,26 +124,23 @@ ref_ptr MDLReader::readTextureFile(std::string textureName) // If we found the file, read it, otherwise bail if (!texPath.empty()) { - texImage = readImageFile(texPath); + texImage = readRefImageFile(texPath); // If we got the image, create the texture attribute - if (texImage != NULL) + if (texImage.valid()) { // Create the texture if (texImage->t() == 1) { - texture = new Texture1D(); - ((Texture1D *)texture)->setImage(texImage); + texture = new Texture1D(texImage.get()); } else if (texImage->r() == 1) { - texture = new Texture2D(); - ((Texture2D *)texture)->setImage(texImage); + texture = new Texture2D(texImage.get()); } else { - texture = new Texture3D(); - ((Texture3D *)texture)->setImage(texImage); + texture = new Texture3D(texImage.get()); } // Set texture attributes diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index 9809ac88b..46bd582e7 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -197,13 +197,13 @@ static void load_material_texture( obj::Model &model, if ( !model.getDatabasePath().empty() ) { // first try with database path of parent. - image = osgDB::readImageFile(model.getDatabasePath()+'/'+filename); + image = osgDB::readRefImageFile(model.getDatabasePath()+'/'+filename); } if ( !image.valid() ) { // if not already set then try the filename as is. - image = osgDB::readImageFile(filename); + image = osgDB::readRefImageFile(filename); } if ( image.valid() ) diff --git a/src/osgPlugins/osgViewer/View.cpp b/src/osgPlugins/osgViewer/View.cpp index e65e9efb9..2f68bfb5b 100644 --- a/src/osgPlugins/osgViewer/View.cpp +++ b/src/osgPlugins/osgViewer/View.cpp @@ -185,7 +185,7 @@ bool View_readLocalData(osg::Object &obj, osgDB::Input &fr) if (!filename.empty()) { - intensityMap = osgDB::readImageFile(filename); + intensityMap = osgDB::readRefImageFile(filename); } if (intensityMap.valid()) diff --git a/src/osgPlugins/osgVolume/ImageLayer.cpp b/src/osgPlugins/osgVolume/ImageLayer.cpp index ef43859c2..8d7e11d3f 100644 --- a/src/osgPlugins/osgVolume/ImageLayer.cpp +++ b/src/osgPlugins/osgVolume/ImageLayer.cpp @@ -57,12 +57,12 @@ bool ImageLayer_readLocalData(osg::Object& obj, osgDB::Input &fr) osg::ref_ptr image; if (fileType == osgDB::DIRECTORY) { - image = osgDB::readImageFile(filename+".dicom"); + image = osgDB::readRefImageFile(filename+".dicom"); } else if (fileType == osgDB::REGULAR_FILE) { - image = osgDB::readImageFile( filename ); + image = osgDB::readRefImageFile( filename ); } osg::notify(osg::NOTICE)<<"image "<getPixelFormat()<<" textureFormat "<getInternalTextureFormat()<<" dataType "<getDataType()< image = osgDB::readRefImageFile(theFile); + if (image.valid()) { - osg_texture->setImage(image); + osg_texture->setImage(image.get()); } else { diff --git a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp index 61bce3859..bffd75928 100644 --- a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp +++ b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp @@ -296,7 +296,7 @@ osg::ref_ptr ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) const std::string &url = mfs.value[0]; - osg::ref_ptr image = osgDB::readImageFile(url); + osg::ref_ptr image = osgDB::readRefImageFile(url); if (image != 0) { osg::ref_ptr texture = new osg::Texture2D; diff --git a/src/osgPlugins/x/ReaderWriterDirectX.cpp b/src/osgPlugins/x/ReaderWriterDirectX.cpp index 48cdac55c..fdfc7de62 100644 --- a/src/osgPlugins/x/ReaderWriterDirectX.cpp +++ b/src/osgPlugins/x/ReaderWriterDirectX.cpp @@ -227,7 +227,7 @@ osg::Geode* ReaderWriterDirectX::convertFromDX(DX::Mesh & mesh, // Share image/texture pairs osg::Texture2D* texture = texForImage[mtl.texture[j]]; if (!texture) { - osg::Image* image = osgDB::readImageFile(mtl.texture[j],options); + osg::ref_ptr image = osgDB::readRefImageFile(mtl.texture[j],options); if (!image) continue; @@ -235,7 +235,7 @@ osg::Geode* ReaderWriterDirectX::convertFromDX(DX::Mesh & mesh, texture = new osg::Texture2D; texForImage[mtl.texture[j]] = texture; - texture->setImage(image); + texture->setImage(image.get()); texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT); }