Changed Texture so that is use lazy updating on texture paramters (Filter/Wrap)

mode by using a _texParamtersDirty flag in combination with an
applyTexParamters(State&) method which does the paramters setting in one
tidy bundle.  This new implementations replaces the CompileFlags submitted
yesterday.

Simplified NodeCallback by remove osg::NodeCallback::Requirements as they
are no longer needed.

Fixed comments in Drawable.

Put guards around cosf definations so that they are only used under Win32/Mac.

Fixed warning in CullVisitor.
This commit is contained in:
Robert Osfield
2002-03-14 16:01:21 +00:00
parent 3a4efd335a
commit e80496d5db
7 changed files with 139 additions and 164 deletions

View File

@@ -177,10 +177,10 @@ class SG_EXPORT Drawable : public Object
/** Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object.*/
void setDrawCallback(DrawCallback* dc) { _drawCallback=dc; dirtyDisplayList(); }
/** Get the non const ComputerTransfromCallback.*/
/** Get the non const DrawCallback.*/
DrawCallback* getDrawCallback() { return _drawCallback.get(); }
/** Get the const ComputerTransfromCallback.*/
/** Get the const DrawCallback.*/
const DrawCallback* getDrawCallback() const { return _drawCallback.get(); }
struct CullCallback : public osg::Referenced
@@ -194,10 +194,10 @@ class SG_EXPORT Drawable : public Object
/** Set the CullCallback which allows users to attach customize the drawing of existing Drawable object.*/
void setCullCallback(CullCallback* cc) { _cullCallback=cc; }
/** Get the non const ComputerTransfromCallback.*/
/** Get the non const CullCallback.*/
CullCallback* getCullCallback() { return _cullCallback.get(); }
/** Get the const ComputerTransfromCallback.*/
/** Get the const CullCallback.*/
const CullCallback* getCullCallback() const { return _cullCallback.get(); }

View File

@@ -8,51 +8,52 @@
#include <math.h>
#if defined(WIN32) || defined (macintosh)
#include <float.h>
// PJA MAC OSX
// This appears to be the simplest way to get these defined under MACOSX
// where they arent in math.h
#ifndef acosf
#define acosf (float)acos
#endif
#ifndef asinf
#define asinf (float)asin
#endif
#ifndef cosf
#define cosf (float)cos
#endif
#ifndef sinf
#define sinf (float)sin
#endif
#ifndef logf
#define logf (float)log
#endif
#ifndef floorf
#define floorf (float)floor
#endif
#ifndef powf
#define powf (float)pow
#endif
#ifndef sqrtf
#define sqrtf (float)sqrt
#endif
#ifndef fabsf
#define fabsf (float)fabs
#endif
#endif
// PJA MAC OSX
// This appears to be the simplest way to get these defined under MACOSX
// where they arent in math.h
#ifndef acosf
#define acosf (float)acos
#endif
#ifndef asinf
#define asinf (float)asin
#endif
#ifndef cosf
#define cosf (float)cos
#endif
#ifndef sinf
#define sinf (float)sin
#endif
#ifndef logf
#define logf (float)log
#endif
#ifndef floorf
#define floorf (float)floor
#endif
#ifndef powf
#define powf (float)pow
#endif
#ifndef sqrtf
#define sqrtf (float)sqrt
#endif
#ifndef fabsf
#define fabsf (float)fabs
#endif
namespace osg {
// define the stand trig values

View File

@@ -16,26 +16,11 @@ class SG_EXPORT NodeCallback : public Referenced {
public :
/** The range of values which can be accumulated by the NodeVisitor. */
enum Requirements
{
NO_REQUIREMENTS = 0x0,
REQUIRES_TRAVERSAL = 0x1,
REQUIRES_PARENT_PATH = 0x2,
REQUIRES_ACCUMULATED_MATRIX = 0x4,
REQUIRES_ACCUMULATED_INVERSE = 0x8
};
NodeCallback(const Requirements ncr=NO_REQUIREMENTS):_requirements(ncr) {}
NodeCallback(){}
virtual ~NodeCallback() {}
/** Set what values from traversal are required by this NodeCallback.*/
inline void setRequirements(const Requirements ncr) { _requirements=ncr; }
/** Get what values from traversal are required by this NodeCallback.*/
inline const Requirements getRequirements() const { return _requirements; }
/** Callback method call by the NodeVisitor when visiting a node.*/
virtual void operator()(Node*, NodeVisitor*) {}
@@ -80,8 +65,6 @@ class SG_EXPORT NodeCallback : public Referenced {
public:
Requirements _requirements;
ref_ptr<NodeCallback> _nestedCallback;
};

View File

@@ -87,6 +87,7 @@ class SG_EXPORT Texture : public StateAttribute
_wrap_r(text._wrap_r),
_min_filter(text._min_filter),
_mag_filter(text._mag_filter),
_texParamtersDirty(false),
_internalFormatMode(text._internalFormatMode),
_internalFormatValue(text._internalFormatValue),
_borderColor(text._borderColor),
@@ -150,9 +151,9 @@ class SG_EXPORT Texture : public StateAttribute
enum WrapMode {
CLAMP = GL_CLAMP,
CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER_ARB,
REPEAT = GL_REPEAT,
MIRROR = GL_MIRRORED_REPEAT_IBM,
CLAMP_TO_BORDER_ARB = GL_CLAMP_TO_BORDER_ARB
MIRROR = GL_MIRRORED_REPEAT_IBM
};
/** Set the texture wrap mode.*/
@@ -161,6 +162,13 @@ class SG_EXPORT Texture : public StateAttribute
const WrapMode getWrap(const WrapParameter which) const;
/** Sets the border color for this texture. Makes difference only if
* wrap mode is CLAMP_TO_BORDER */
void setBorderColor(const Vec4& color) { _borderColor = color; _texParamtersDirty = true; }
const Vec4& borderColor(void) const { return _borderColor; }
enum FilterParameter {
MIN_FILTER,
MAG_FILTER
@@ -182,22 +190,6 @@ class SG_EXPORT Texture : public StateAttribute
/** 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,
@@ -299,10 +291,6 @@ class SG_EXPORT Texture : public StateAttribute
* does not set or use texture binding. */
virtual void applyImmediateMode(State& state) const;
/** Sets the border color for this texture. Makes difference only if
* wrap mode is CLAMP_TO_BORDER_ARB */
void setBorderColor(const Vec4& color) {_borderColor = color;}
const Vec4& borderColor(void) const {return _borderColor;}
/** use deleteTextureObject instead of glDeleteTextures to allow
@@ -320,6 +308,9 @@ class SG_EXPORT Texture : public StateAttribute
virtual ~Texture();
void applyTexParameters(State& state) const;
typedef std::vector<GLuint> TextureNameList;
mutable TextureNameList _handleList;
@@ -329,6 +320,7 @@ class SG_EXPORT Texture : public StateAttribute
// size of the created OpenGL texture object, may be estimated.
mutable uint _textureObjectSize;
// not ideal that _image is mutable, but its required since
// Image::ensureDimensionsArePowerOfTwo() can only be called
// in a valid OpenGL context, a therefore within an Texture::apply
@@ -344,7 +336,9 @@ class SG_EXPORT Texture : public StateAttribute
FilterMode _min_filter;
FilterMode _mag_filter;
CompileFlags _compile_flags;
// true if apply tex parameters required.
mutable bool _texParamtersDirty;
InternalFormatMode _internalFormatMode;
int _internalFormatValue;