1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 22:11:34 +00:00

skip flipping of 3D textures which is unsupported in OSG

This commit is contained in:
cody glassman 2022-05-14 23:06:32 -07:00
parent 0cb63ca4e6
commit ac6089a430
3 changed files with 6 additions and 4 deletions

View file

@ -470,7 +470,7 @@ namespace fx
else if (key == "source") else if (key == "source")
{ {
expect<Lexer::String>(); expect<Lexer::String>();
auto image = mImageManager.getImage(std::string{std::get<Lexer::String>(mToken).value}); auto image = mImageManager.getImage(std::string{std::get<Lexer::String>(mToken).value}, is3D);
if constexpr (is1D) if constexpr (is1D)
{ {
type = Types::SamplerType::Texture_1D; type = Types::SamplerType::Texture_1D;

View file

@ -49,6 +49,7 @@ namespace Resource
: ResourceManager(vfs) : ResourceManager(vfs)
, mWarningImage(createWarningImage()) , mWarningImage(createWarningImage())
, mOptions(new osgDB::Options("dds_flip dds_dxt1_detect_rgba ignoreTga2Fields")) , mOptions(new osgDB::Options("dds_flip dds_dxt1_detect_rgba ignoreTga2Fields"))
, mOptionsNoFlip(new osgDB::Options("dds_dxt1_detect_rgba ignoreTga2Fields"))
{ {
} }
@ -82,7 +83,7 @@ namespace Resource
return true; return true;
} }
osg::ref_ptr<osg::Image> ImageManager::getImage(const std::string &filename) osg::ref_ptr<osg::Image> ImageManager::getImage(const std::string &filename, bool disableFlip)
{ {
const std::string normalized = mVFS->normalizeFilename(filename); const std::string normalized = mVFS->normalizeFilename(filename);
@ -135,7 +136,7 @@ namespace Resource
stream->seekg(0); stream->seekg(0);
} }
osgDB::ReaderWriter::ReadResult result = reader->readImage(*stream, mOptions); osgDB::ReaderWriter::ReadResult result = reader->readImage(*stream, disableFlip ? mOptionsNoFlip : mOptions);
if (!result.success()) if (!result.success())
{ {
Log(Debug::Error) << "Error loading " << filename << ": " << result.message() << " code " << result.status(); Log(Debug::Error) << "Error loading " << filename << ": " << result.message() << " code " << result.status();

View file

@ -28,7 +28,7 @@ namespace Resource
/// Create or retrieve an Image /// Create or retrieve an Image
/// Returns the dummy image if the given image is not found. /// Returns the dummy image if the given image is not found.
osg::ref_ptr<osg::Image> getImage(const std::string& filename); osg::ref_ptr<osg::Image> getImage(const std::string& filename, bool disableFlip = false);
osg::Image* getWarningImage(); osg::Image* getWarningImage();
@ -37,6 +37,7 @@ namespace Resource
private: private:
osg::ref_ptr<osg::Image> mWarningImage; osg::ref_ptr<osg::Image> mWarningImage;
osg::ref_ptr<osgDB::Options> mOptions; osg::ref_ptr<osgDB::Options> mOptions;
osg::ref_ptr<osgDB::Options> mOptionsNoFlip;
ImageManager(const ImageManager&); ImageManager(const ImageManager&);
void operator = (const ImageManager&); void operator = (const ImageManager&);