From fea861e013c61d1ac65486a70f18e41ff9181808 Mon Sep 17 00:00:00 2001 From: Don BURNS Date: Thu, 14 Mar 2002 00:07:29 +0000 Subject: [PATCH] Fixed compile flags in Texture --- include/osg/Texture | 19 +++++++++++++++++++ src/osg/Texture.cpp | 11 ++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/osg/Texture b/include/osg/Texture index dca2dcc15..62e55db8e 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -176,11 +176,28 @@ class SG_EXPORT Texture : public StateAttribute ANISOTROPIC = GL_TEXTURE_MAX_ANISOTROPY_EXT }; + /** Set the texture filter mode.*/ void setFilter(const FilterParameter which, const FilterMode filter); /** Get the texture filter mode.*/ const FilterMode getFilter(const FilterParameter which) const; + enum CompileFlags { + COMPILE_NONE = 0x0, + COMPILE_MAG_FILTER = 0x1, + COMPILE_MIN_FILTER = 0x2, + COMPILE_WRAP_S = 0x4, + COMPILE_WRAP_T = 0x8, + COMPILE_ALL = 0xFF + }; + + /** Set the compile flags. Whatever is set will be compiled + ** when the texture object is built. Otherwise, immediate mode + ** setting of these modes will occur during the apply + **/ + void setCompileFlags( const CompileFlags compile_flags ) { _compile_flags = compile_flags; } + const CompileFlags getCompileFlags( void ) const { return _compile_flags; } + enum InternalFormatMode { USE_IMAGE_DATA_FORMAT, @@ -327,6 +344,8 @@ class SG_EXPORT Texture : public StateAttribute FilterMode _min_filter; FilterMode _mag_filter; + CompileFlags _compile_flags; + InternalFormatMode _internalFormatMode; int _internalFormatValue; diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index f2b3a5f0d..c5f94a017 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -42,6 +42,8 @@ Texture::Texture() _subloadOffsX = _subloadOffsY = 0; _borderColor.set(0.0, 0.0, 0.0, 0.0);//OpenGL default + + _compile_flags = COMPILE_ALL; } @@ -191,7 +193,14 @@ void Texture::apply(State& state) const if (_subloadMode == OFF) { glBindTexture( GL_TEXTURE_2D, handle ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _min_filter); + if( !(_compile_flags & COMPILE_MIN_FILTER) ) + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _min_filter); + if( !(_compile_flags & COMPILE_MAG_FILTER) ) + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _mag_filter); + if( !(_compile_flags & COMPILE_WRAP_S) ) + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _wrap_s ); + if( !(_compile_flags & COMPILE_WRAP_T) ) + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _wrap_t ); } else if (_image.valid() && _image->data()) {