From b049865cb2579e72f2cc3d30b90d0551cdc4674c Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Fri, 13 Mar 2020 18:28:34 +0100 Subject: [PATCH] fixes #2123 Relocation splash distorted. Mark images loaded from splash with origin of splash to prevent use of DDS texture cache and therefore fix distortion by preventing rescale to power of two --- src/Viewer/splash.cxx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Viewer/splash.cxx b/src/Viewer/splash.cxx index 7064ef539..6fc8cf6dc 100644 --- a/src/Viewer/splash.cxx +++ b/src/Viewer/splash.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include
#include
@@ -56,6 +57,7 @@ #include + static const char* LICENSE_URL_TEXT = "Licensed under the GNU GPL. See http://www.flightgear.org for more information"; class SplashScreenUpdateCallback : public osg::NodeCallback { @@ -81,13 +83,21 @@ SplashScreen::~SplashScreen() void SplashScreen::createNodes() { + std::string splashImage = selectSplashImage(); #if OSG_VERSION_LESS_THAN(3,4,0) - _splashImage = osgDB::readImageFile(selectSplashImage()); + _splashImage = osgDB::readImageFile(splashImage); #else - _splashImage = osgDB::readRefImageFile(selectSplashImage()); + auto staticOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); + staticOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); + _splashImage = osgDB::readRefImageFile(splashImage, staticOptions); +// _splashImage = osgDB::readRefImageFile(selectSplashImage()); #endif - int width = _splashImage->s(); + if (!_splashImage){ + SG_LOG(SG_VIEW, SG_INFO, "Splash Image " << splashImage << " failed to load"); + return; + } + int width = _splashImage->s(); int height = _splashImage->t(); _splashImageAspectRatio = static_cast(width) / height; @@ -287,9 +297,12 @@ void SplashScreen::setupLogoImage() #if OSG_VERSION_LESS_THAN(3,4,0) _logoImage = osgDB::readImageFile(logoPath.utf8Str()); #else - _logoImage = osgDB::readRefImageFile(logoPath.utf8Str()); + auto staticOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); + staticOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); + _logoImage = osgDB::readRefImageFile(logoPath.utf8Str(), staticOptions); #endif if (!_logoImage) { + SG_LOG(SG_VIEW, SG_INFO, "Splash logo image " << logoPath << " failed to load"); return; }