From: frohlich Date: Mon, 28 May 2007 05:13:03 +0000 (+0000) Subject: Modified Files: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f32e037c584c9a2e7ad7e197500ce7b8b573e3ee;p=simgear.git Modified Files: simgear/scene/material/mat.cxx simgear/scene/material/mat.hxx: Olaf Flebbe: Improoved texture filtering. --- diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 59577190..646a0e53 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -49,6 +49,7 @@ SG_USING_STD(map); #include #include + #include "mat.hxx" static map > _tex_cache; @@ -141,7 +142,6 @@ SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props wrapu = props->getBoolValue("wrapu", true); wrapv = props->getBoolValue("wrapv", true); mipmap = props->getBoolValue("mipmap", true); - filtering = props->getDoubleValue("filtering", 1.0); light_coverage = props->getDoubleValue("light-coverage", 0.0); // surface values for use with ground reactions @@ -205,7 +205,6 @@ SGMaterial::init () wrapv = true; mipmap = true; - filtering = 1.0f; light_coverage = 0.0; solid = true; @@ -235,7 +234,7 @@ SGMaterial::load_texture ( int n ) SG_LOG( SG_GENERAL, SG_INFO, "Loading deferred texture " << _status[i].texture_path ); assignTexture(_status[i].state.get(), _status[i].texture_path, - wrapu, wrapv, mipmap, filtering ); + wrapu, wrapv, mipmap); _status[i].texture_loaded = true; } } @@ -282,7 +281,7 @@ SGMaterial::build_state( bool defer_tex_load ) if ( !defer_tex_load ) { SG_LOG(SG_INPUT, SG_INFO, " " << _status[i].texture_path ); - assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv, 1, filtering ); + assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv); _status[i].texture_loaded = true; } else { _status[i].texture_loaded = false; @@ -319,7 +318,7 @@ void SGMaterial::set_state( osg::StateSet *s ) } void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname, - int _wrapu, int _wrapv, int _mipmap, float filtering ) + int _wrapu, int _wrapv, int _mipmap ) { map >::iterator _tex_cache_iter; _tex_cache_iter = _tex_cache.find(fname); @@ -327,7 +326,7 @@ void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname, { osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv, mipmap ? -1 : 0); - texture->setMaxAnisotropy( filtering); + texture->setMaxAnisotropy( SGTextureFilterListener::getFilter()); state->setTextureAttributeAndModes(0, texture); _tex_cache[fname] = texture; } @@ -362,5 +361,15 @@ SGMaterialGlyph::SGMaterialGlyph(SGPropertyNode *p) : { } +//////////////////////////////////////////////////////////////////////// +// SGTextureFilterListener +//////////////////////////////////////////////////////////////////////// + + +int SGTextureFilterListener::filter = 1; +int SGTextureFilterListener::getFilter() { return filter; }; +void SGTextureFilterListener::setFilter(int filt) { + filter = filt; +}; // end of mat.cxx diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 9e93343f..648abcab 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -53,6 +53,17 @@ SG_USING_STD(map); class SGMaterialGlyph; +class SGTextureFilterListener { +private: + static int filter; + + SGTextureFilterListener() { + } + +public: + static int getFilter(); + static void setFilter(int filt); + }; /** * A material in the scene graph. @@ -121,7 +132,6 @@ public: */ bool load_texture (int n = -1); - /** * Get the textured state. */ @@ -266,9 +276,6 @@ private: // use mipmapping? int mipmap; - // use anisotropic filtering - float filtering; - // coverage of night lighting. double light_coverage; @@ -310,7 +317,7 @@ private: void build_state( bool defer_tex_load ); void set_state( osg::StateSet *s ); - void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE, float filtering = 1.0f ); + void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE ); };