From Colin McDonald, fixed image size calculation in getTotalSizeInBytesIncludingMipmaps(),
added checks on success of opening files for writing in the .ive plugin.
This commit is contained in:
@@ -308,9 +308,11 @@ unsigned int Image::getTotalSizeInBytesIncludingMipmaps() const
|
||||
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
|
||||
sizeOfLastMipMap = maximum(sizeOfLastMipMap, 8u); // block size of 8
|
||||
break;
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
|
||||
sizeOfLastMipMap = maximum(sizeOfLastMipMap, 16u); // block size of 16
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace osgDB;
|
||||
bool osgDB::writeObjectFile(const Object& object,const std::string& filename)
|
||||
{
|
||||
ReaderWriter::WriteResult wr = Registry::instance()->writeObject(object,filename);
|
||||
if (wr.error()) notify(WARN) << wr.message() << std::endl;
|
||||
if (wr.error()) notify(WARN) << "Error writing file " << filename << ": " << wr.message() << std::endl;
|
||||
return wr.success();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ bool osgDB::writeObjectFile(const Object& object,const std::string& filename)
|
||||
bool osgDB::writeImageFile(const Image& image,const std::string& filename)
|
||||
{
|
||||
ReaderWriter::WriteResult wr = Registry::instance()->writeImage(image,filename);
|
||||
if (wr.error()) notify(WARN) << wr.message() << std::endl;
|
||||
if (wr.error()) notify(WARN) << "Error writing file " << filename << ": " << wr.message() << std::endl;
|
||||
return wr.success();
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ bool osgDB::writeImageFile(const Image& image,const std::string& filename)
|
||||
bool osgDB::writeHeightFieldFile(const HeightField& HeightField,const std::string& filename)
|
||||
{
|
||||
ReaderWriter::WriteResult wr = Registry::instance()->writeHeightField(HeightField,filename);
|
||||
if (wr.error()) notify(WARN) << wr.message() << std::endl;
|
||||
if (wr.error()) notify(WARN) << "Error writing file " << filename << ": " << wr.message() << std::endl;
|
||||
return wr.success();
|
||||
}
|
||||
|
||||
bool osgDB::writeNodeFile(const Node& node,const std::string& filename)
|
||||
{
|
||||
ReaderWriter::WriteResult wr = Registry::instance()->writeNode(node,filename);
|
||||
if (wr.error()) notify(WARN) << wr.message() << std::endl;
|
||||
if (wr.error()) notify(WARN) << "Error writing file " << filename << ": " << wr.message() << std::endl;
|
||||
return wr.success();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ class IVEReaderWriter : public ReaderWriter
|
||||
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
WriteResult result = writeNode(node, fout, local_opt.get());
|
||||
fout.close();
|
||||
return result;
|
||||
@@ -103,6 +105,9 @@ class IVEReaderWriter : public ReaderWriter
|
||||
out.setOptions(options);
|
||||
|
||||
out.writeNode(const_cast<osg::Node*>(&node));
|
||||
|
||||
if ( fout.fail() ) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return WriteResult::FILE_SAVED;
|
||||
}
|
||||
catch(ive::Exception e)
|
||||
|
||||
Reference in New Issue
Block a user