From 65925cccdfaab9ed2b099b2aa150e1c536cd408e Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 5 May 2020 20:40:29 +0100 Subject: [PATCH] Enable old-style texture compression Thanks to Dany for tracking this down! --- simgear/scene/model/ModelRegistry.cxx | 8 ----- simgear/scene/util/SGSceneFeatures.cxx | 46 +++++++++++++------------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 9678a3ef..b2789bcd 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -113,9 +113,6 @@ protected: } }; -// disabling old-syle texture compression in favour of the -// texture-cache -#if 0 class SGTexCompressionVisitor : public SGTextureStateAttributeVisitor { public: virtual void apply(int, StateSet::RefAttributePair& refAttr) @@ -146,7 +143,6 @@ public: } } }; -#endif class SGTexDataVarianceVisitor : public SGTextureStateAttributeVisitor { public: @@ -644,12 +640,8 @@ osg::Node* OptimizeModelPolicy::optimize(osg::Node* node, SGTexDataVarianceVisitor dataVarianceVisitor; node->accept(dataVarianceVisitor); -// disabling old-syle texture compression in favour of the -// texture-cache -#if 0 SGTexCompressionVisitor texComp; node->accept(texComp); -#endif return node; } diff --git a/simgear/scene/util/SGSceneFeatures.cxx b/simgear/scene/util/SGSceneFeatures.cxx index f04ff858..04b46a01 100644 --- a/simgear/scene/util/SGSceneFeatures.cxx +++ b/simgear/scene/util/SGSceneFeatures.cxx @@ -69,29 +69,29 @@ SGSceneFeatures::instance() void SGSceneFeatures::applyTextureCompression(osg::Texture* texture) const { - // disable older texture-compression, since it interacts confusingly - // with the the runtime texture-cache. We always want to use - // 'USE_IMAGE_DATA_FORMAT' when the texture-cache is active, since we - // decided whether to compress (or not) prior to this point. -#if 0 - switch (_textureCompression) { - case UseARBCompression: - texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION); - break; - case UseDXT1Compression: - texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT1_COMPRESSION); - break; - case UseDXT3Compression: - texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION); - break; - case UseDXT5Compression: - texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT5_COMPRESSION); - break; - default: - texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); - break; - } -#endif + // if the texture cache is active, always use the file data format + if (_TextureCacheCompressionActive) { + texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); + } else { + // keep the older texture compression working, some people need it + switch (_textureCompression) { + case UseARBCompression: + texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION); + break; + case UseDXT1Compression: + texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT1_COMPRESSION); + break; + case UseDXT3Compression: + texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION); + break; + case UseDXT5Compression: + texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT5_COMPRESSION); + break; + default: + texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); + break; + } + } } bool