Removed deprecated code from the distribution.

Added .osg support for Texture1D and Texture3D.
This commit is contained in:
Robert Osfield
2002-08-28 15:28:11 +00:00
parent 951b6e9f3f
commit 8353fc0ed6
41 changed files with 911 additions and 1823 deletions

View File

@@ -49,12 +49,7 @@ class SG_EXPORT BoundingBox
_min.set(FLT_MAX,FLT_MAX,FLT_MAX);
_max.set(-FLT_MAX,-FLT_MAX,-FLT_MAX);
}
#ifdef USE_DEPRECATED_API
/** deprecated, use valid() instead.*/
inline const bool isValid() const { return _max.x()>=_min.x(); }
#endif
inline const bool valid() const
{
return _max.x()>=_min.x();

View File

@@ -38,10 +38,6 @@ class SG_EXPORT BoundingSphere
_radius = -1.0f;
}
#ifdef USE_DEPRECATED_API
/** deprecated, use valid() instead.*/
inline const bool isValid() const { return _radius>=0.0f; }
#endif
/** return true if the bounding sphere contains valid values,
false if the bounding sphere is effectively unset.*/
inline const bool valid() const { return _radius>=0.0f; }

View File

@@ -13,7 +13,7 @@ class Referenced;
class Object;
class Image;
//class Texture;
class TextureBase;
class Texture;
class StateSet;
class StateAttribute;
class Node;
@@ -54,8 +54,7 @@ class SG_EXPORT CopyOp
virtual Drawable* operator() (const Drawable* drawable) const;
virtual StateSet* operator() (const StateSet* stateset) const;
virtual StateAttribute* operator() (const StateAttribute* attr) const;
// virtual Texture* operator() (const Texture* text) const;
virtual TextureBase* operator() (const TextureBase* text) const;
virtual Texture* operator() (const Texture* text) const;
virtual Image* operator() (const Image* image) const;
virtual Array* operator() (const Array* image) const;
virtual Primitive* operator() (const Primitive* image) const;

View File

@@ -1,18 +0,0 @@
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSG_EARTHSKY
#define OSG_EARTHSKY 1
#include <osg/ClearNode>
namespace osg {
#ifdef USE_DEPRECATED_API
typedef ClearNode EarthSky;
#endif
}
#endif

View File

@@ -167,17 +167,6 @@ class SG_EXPORT Matrix : public Object
inline static Matrix lookAt(const Vec3& eye,const Vec3& center,const Vec3& up);
#ifdef USE_DEPRECATED_API
/** make a rotation Matrix from euler angles.
* assume Z up, Y north, X east and euler convention
* as per Open Flight & Performer.
* Applies a positive rotation about Y axis for roll,
* then applies a positive roation about X for pitch,
* and finally a negative rotation about the Z axis.*/
void makeRotate( float heading, float pitch, float roll); //Euler angles
inline static Matrix rotate( float heading, float pitch, float roll);
#endif
inline Vec3 preMult( const Vec3& v ) const;
@@ -299,14 +288,6 @@ inline Matrix Matrix::rotate(float angle, const Vec3& axis )
m.makeRotate(angle,axis);
return m;
}
#ifdef USE_DEPRECATED_API
inline Matrix Matrix::rotate(float heading, float pitch, float roll)
{
Matrix m;
m.makeRotate(heading,pitch,roll);
return m;
}
#endif
inline Matrix Matrix::rotate( float angle1, const Vec3& axis1,
float angle2, const Vec3& axis2,
float angle3, const Vec3& axis3)

View File

@@ -225,18 +225,8 @@ class SG_EXPORT Quat
Watch out for the two special cases of when the vectors
are co-incident or opposite in direction.*/
void makeRotate( const Vec3& vec1, const Vec3& vec2 );
#ifdef USE_DEPRECATED_API
/** make a rotation Quat from euler angles.
* assume Z up, Y north, X east and euler convention
* as per Open Flight & Performer.
* Applies a positive rotation about Y axis for roll,
* then applies a positive roation about X for pitch,
* and finally a negative rotation about the Z axis.*/
void makeRotate( float heading, float pitch, float roll);
#endif
/** Return the angle and vector components represented by the quaternion.*/
/** Return the angle and vector components represented by the quaternion.*/
void getRotate ( float& angle, float& x, float& y, float& z ) const;
/** Return the angle and vector represented by the quaternion.*/
void getRotate ( float& angle, Vec3& vec ) const;

View File

@@ -82,12 +82,6 @@ class SG_EXPORT StateAttribute : public Object
OVERRIDE = 0x2,
/** Protecting of GLMode's os StateAttributes is enabled, so that state from above connot override this and below state.*/
PROTECTED = 0x4,
#ifdef USE_DEPRECATED_API
/** Equivilant to OFF | OVERRIDE.*/
OVERRIDE_OFF = 0x2,
/** Equivilant to ON | OVERRIDE.*/
OVERRIDE_ON = 0x3,
#endif
/** means that GLMode or StateAttribute should in inherited from above.*/
INHERIT = 0x8
};

View File

@@ -2,216 +2,282 @@
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
// -*-c++-*-
//#define TEXTURE_USE_DEPRECATED_API
#ifdef TEXTURE_USE_DEPRECATED_API
#ifndef OSG_TEXTURE
#define OSG_TEXTURE 1
#include <osg/TextureBase>
#include <osg/GL>
#include <osg/Types>
#include <osg/Image>
#include <osg/StateAttribute>
#include <osg/ref_ptr>
#include <osg/Vec4>
#include <vector>
#include <map>
#include <set>
// if not defined by gl.h use the definition found in:
// http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#endif
#ifndef GL_ARB_texture_compression
#define GL_COMPRESSED_ALPHA_ARB 0x84E9
#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
#define GL_COMPRESSED_RGB_ARB 0x84ED
#define GL_COMPRESSED_RGBA_ARB 0x84EE
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
#define GL_TEXTURE_IMAGE_SIZE_ARB 0x86A0
#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
#endif
#ifndef GL_EXT_texture_compression_s3tc
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
#endif
#ifndef GL_MIRRORED_REPEAT_IBM
#define GL_MIRRORED_REPEAT_IBM 0x8370
#endif
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
#ifndef GL_CLAMP_TO_BORDER_ARB
#define GL_CLAMP_TO_BORDER_ARB 0x812D
#endif
#ifndef GL_GENERATE_MIPMAP_SGIS
#define GL_GENERATE_MIPMAP_SGIS 0x8191
#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
#endif
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D 0x806F
#endif
namespace osg {
/** Texture state class which encapsulates OpenGl texture functionality.*/
class SG_EXPORT Texture : public TextureBase
/** Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.*/
class SG_EXPORT Texture : public osg::StateAttribute
{
public :
Texture();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
Texture(const Texture& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual osg::Object* cloneType() const = 0;
virtual osg::Object* clone(const CopyOp& copyop) const = 0;
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Texture *>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "Texture"; }
virtual const Type getType() const { return TEXTURE; }
virtual bool isTextureAttribute() const { return true; }
enum WrapParameter {
WRAP_S,
WRAP_T,
WRAP_R
};
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
};
/** Set the texture wrap mode.*/
void setWrap(const WrapParameter which, const WrapMode wrap);
/** Get the texture wrap mode.*/
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; _texParametersDirty = true; }
const Vec4& borderColor(void) const { return _borderColor; }
META_StateAttribute(osg, Texture,TEXTURE);
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
virtual int compare(const StateAttribute& rhs) const;
enum FilterParameter {
MIN_FILTER,
MAG_FILTER
};
virtual void getAssociatedModes(std::vector<GLMode>& modes) const
{
modes.push_back(GL_TEXTURE_2D);
}
enum FilterMode {
LINEAR = GL_LINEAR,
LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR,
LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
NEAREST = GL_NEAREST,
NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST
};
/** Set the texture image. */
void setImage(Image* image);
/** Get the texture image. */
Image* getImage() { return _image.get(); }
/** Set the texture filter mode.*/
void setFilter(const FilterParameter which, const FilterMode filter);
/** Get the const texture image. */
inline const Image* getImage() const { return _image.get(); }
/** Get the texture filter mode.*/
const FilterMode getFilter(const FilterParameter which) const;
/** Copy pixels into a 2D texture image.As per glCopyTexImage2D.
* Creates an OpenGL texture object from the current OpenGL background
* framebuffer contents at pos \a x, \a y with width \a width and
* height \a height. \a width and \a height must be a power of two.
/** Set the maximum anisotropy value, default value is 1.0 for
* no anisotropic filtering. If hardware does not support anisotropic
* filtering then normal filtering is used, equivilant to a max anisotropy value of 1.0.
* valid range is 1.0f upwards. The maximum value depends on the graphics
* system being used.*/
void setMaxAnisotropy(float anis);
/** Get the maximum anisotropy value.*/
inline float getMaxAnisotropy() const { return _maxAnisotropy; }
enum InternalFormatMode {
USE_IMAGE_DATA_FORMAT,
USE_USER_DEFINED_FORMAT,
USE_ARB_COMPRESSION,
USE_S3TC_DXT1_COMPRESSION,
USE_S3TC_DXT3_COMPRESSION,
USE_S3TC_DXT5_COMPRESSION
};
/** Set the internal format mode.
* Note, If the mode is set USE_IMAGE_DATA_FORMAT, USE_ARB_COMPRESSION,
* USE_S3TC_COMPRESSION the internalFormat is automatically selected,
* and will overwrite the previous _internalFormat.
*/
void copyTexImage2D(State& state, int x, int y, int width, int height );
/** Copy a two-dimensional texture subimage. As per glCopyTexSubImage2D.
* Updates portion of an existing OpenGL texture object from the current OpenGL background
* framebuffer contents at pos \a x, \a y with width \a width and
* height \a height. \a width and \a height must be a power of two,
* and writing into the texture with offset \a xoffset and \a yoffset.
*/
void copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height );
inline void setInternalFormatMode(const InternalFormatMode mode) { _internalFormatMode = mode; }
/** Get the internal format mode.*/
inline const InternalFormatMode getInternalFormatMode() const { return _internalFormatMode; }
/** Set the internal format to use when creating OpenGL textures.
* Also sets the internalFormatMode to USE_USER_DEFINED_FORMAT.
*/
inline void setInternalFormatValue(const int internalFormat)
inline void setInternalFormat(const int internalFormat)
{
_internalFormatMode = USE_USER_DEFINED_FORMAT;
_internalFormat = internalFormat;
}
/** Get the internal format to use when creating OpenGL textures.*/
inline const int getInternalFormatValue() const { return _internalFormat; }
inline const int getInternalFormat() const { if (_internalFormat==0) computeInternalFormat(); return _internalFormat; }
bool isCompressedInternalFormat() const;
enum SubloadMode {
OFF,
AUTO,
IF_DIRTY,
USE_CALLBACK
};
/** Set the texture subload mode. */
inline void setSubloadMode(const SubloadMode mode) { _subloadMode = mode; }
/** Get the texture subload mode. */
inline const SubloadMode getSubloadMode() const { return _subloadMode; }
/** Set the texture subload texture offsets. */
inline void setSubloadTextureOffset(const int x, const int y)
{
_subloadTextureOffsetX = x;
_subloadTextureOffsetY = y;
}
/** Get the texture subload texture offsets. */
inline void getSubloadTextureOffset(int& x, int& y) const
{
x = _subloadTextureOffsetX;
y = _subloadTextureOffsetY;
}
/** Set the texture subload width. If width or height are zero then
* the repsective size value is calculated from the source image sizes. */
inline void setSubloadTextureSize(const int width, const int height) const
/** Get the handle to the texture object for the current context.*/
/** return the OpenGL texture object for specified context.*/
inline GLuint& getTextureObject(const uint contextID) const
{
_textureWidth = width;
_textureHeight = height;
// pad out handle list if required.
if (_handleList.size()<=contextID)
_handleList.resize(contextID+1,0);
// get the globj for the current contextID.
return _handleList[contextID];
}
/** Get the texture subload width. */
inline void getSubloadTextureSize(int& width, int& height) const
inline uint& getModifiedTag(const uint contextID) const
{
width = _textureWidth;
height = _textureHeight;
// pad out handle list if required.
if (_modifiedTag.size()<=contextID)
_modifiedTag.resize(contextID+1,0);
// get the modified tag for the current contextID.
return _modifiedTag[contextID];
}
/** Force a recompile on next apply() of associated OpenGL texture objects.*/
void dirtyTextureObject();
/** Set the subload image offsets. */
inline void setSubloadImageOffset(const int x, const int y)
{
_subloadImageOffsetX = x;
_subloadImageOffsetY = y;
}
/** Get the subload image offsets. */
inline void getSubloadImageOffset(int& x, int& y) const
{
x = _subloadImageOffsetX;
y = _subloadImageOffsetY;
}
/** Set the image subload width. If width or height are zero then
* the repsective size value is calculated from the source image sizes. */
inline void setSubloadImageSize(const int width, const int height)
{
_subloadImageWidth = width;
_subloadImageHeight = height;
}
/** use deleteTextureObject instead of glDeleteTextures to allow
* OpenGL texture objects to cached until they can be deleted
* by the OpenGL context in which they were created, specified
* by contextID.*/
static void deleteTextureObject(uint contextID,GLuint handle);
/** Get the image subload width. */
inline void getSubloadImageSize(int& width, int& height) const
{
width = _subloadImageWidth;
height = _subloadImageHeight;
}
class SubloadCallback : public Referenced
{
public:
virtual void load(GLenum target, const Texture& texture,State& state) const = 0;
virtual void subload(GLenum target, const Texture& texture,State& state) const = 0;
};
/** flush all the cached display list which need to be deleted
* in the OpenGL context related to contextID.*/
static void flushDeletedTextureObjects(uint contextID);
void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb; _subloadMode = cb ? USE_CALLBACK:OFF; }
/** Get the maximum texture size supported, this is the
normally define by GL_MAX_TEXTURE_SIZE, but can be overridden
by the OSG_MAX_TEXTURE_SIZE environmental variable.*/
static GLint getMaxTextureSize();
SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
/** Texture is pure virtual base class, apply must be overriden. */
virtual void apply(State& state) const = 0;
const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
/** Set the number of mip map levels the the texture has been created with,
should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
void setNumMipmapLevels(unsigned int num) const { _numMimpmapLevels=num; }
/** Get the number of mip map levels the the texture has been created with.*/
unsigned int getNumMipmapLevels() const { return _numMimpmapLevels; }
/** On first apply (unless already compiled), create the minmapped
* texture and bind it, subsequent apply will simple bind to texture.*/
virtual void apply(State& state) const;
/** Calls apply(state) to compile the texture. */
virtual void compile(State& state) const;
protected :
virtual ~Texture();
virtual void computeInternalFormat() const;
// 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
// which is const...
mutable ref_ptr<Image> _image;
// subloaded images can have different texture and image sizes.
mutable GLsizei _textureWidth, _textureHeight;
virtual void computeInternalFormat() const = 0;
// number of mip map levels the the texture has been created with,
mutable GLsizei _numMimpmapLevels;
void computeInternalFormatWithImage(osg::Image& image) const;
SubloadMode _subloadMode;
GLint _subloadTextureOffsetX, _subloadTextureOffsetY;
GLint _subloadImageOffsetX, _subloadImageOffsetY;
GLsizei _subloadImageWidth, _subloadImageHeight;
bool isCompressedInternalFormat(GLint internalFormat) const;
ref_ptr<SubloadCallback> _subloadCallback;
/** Helper method which does setting of texture paramters. */
void applyTexParameters(GLenum target, State& state) const;
/** Helper method which does the creation of the texture itself, and
* does not set or use texture binding. */
void applyTexImage2D(GLenum target, Image* image, State& state, GLsizei& width, GLsizei& height,GLsizei& numMimpmapLevels) const;
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
int compareTexture(const Texture& rhs) const;
typedef std::vector<GLuint> TextureNameList;
mutable TextureNameList _handleList;
typedef std::vector<uint> ImageModifiedTag;
mutable ImageModifiedTag _modifiedTag;
WrapMode _wrap_s;
WrapMode _wrap_t;
WrapMode _wrap_r;
FilterMode _min_filter;
FilterMode _mag_filter;
float _maxAnisotropy;
Vec4 _borderColor;
// true if apply tex parameters required.
mutable bool _texParametersDirty;
InternalFormatMode _internalFormatMode;
mutable GLint _internalFormat;
// static cache of deleted display lists which can only
// by completely deleted once the appropriate OpenGL context
// is set.
typedef std::map<uint,std::set<uint> > DeletedTextureObjectCache;
static DeletedTextureObjectCache s_deletedTextureObjectCache;
};
}
#endif
#else // USE_DEPRECATED_API
#ifdef USE_DEPRECATED_API
#include <osg/Texture2D>
namespace osg {
typedef Texture2D Texture;
}
#endif
#endif // USE_DEPRECATED_API

View File

@@ -7,12 +7,12 @@
#ifndef OSG_TEXTURE1D
#define OSG_TEXTURE1D 1
#include <osg/TextureBase>
#include <osg/Texture>
namespace osg {
/** Texture state class which encapsulates OpenGl 1D texture functionality.*/
class SG_EXPORT Texture1D : public TextureBase
class SG_EXPORT Texture1D : public Texture
{
public :

View File

@@ -7,12 +7,12 @@
#ifndef OSG_TEXTURE2D
#define OSG_TEXTURE2D 1
#include <osg/TextureBase>
#include <osg/Texture>
namespace osg {
/** Texture state class which encapsulates OpenGl texture functionality.*/
class SG_EXPORT Texture2D : public TextureBase
class SG_EXPORT Texture2D : public Texture
{
public :

View File

@@ -7,12 +7,12 @@
#ifndef OSG_TEXTURE3D
#define OSG_TEXTURE3D 1
#include <osg/TextureBase>
#include <osg/Texture>
namespace osg {
/** Texture state class which encapsulates OpenGl 3D texture functionality.*/
class SG_EXPORT Texture3D : public TextureBase
class SG_EXPORT Texture3D : public Texture
{
public :

View File

@@ -1,283 +0,0 @@
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSG_TEXTUREBASE
#define OSG_TEXTUREBASE 1
#include <osg/GL>
#include <osg/Types>
#include <osg/Image>
#include <osg/StateAttribute>
#include <osg/ref_ptr>
#include <osg/Vec4>
#include <vector>
#include <map>
#include <set>
// if not defined by gl.h use the definition found in:
// http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#endif
#ifndef GL_ARB_texture_compression
#define GL_COMPRESSED_ALPHA_ARB 0x84E9
#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
#define GL_COMPRESSED_RGB_ARB 0x84ED
#define GL_COMPRESSED_RGBA_ARB 0x84EE
#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
#define GL_TEXTURE_IMAGE_SIZE_ARB 0x86A0
#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
#endif
#ifndef GL_EXT_texture_compression_s3tc
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
#endif
#ifndef GL_MIRRORED_REPEAT_IBM
#define GL_MIRRORED_REPEAT_IBM 0x8370
#endif
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
#ifndef GL_CLAMP_TO_BORDER_ARB
#define GL_CLAMP_TO_BORDER_ARB 0x812D
#endif
#ifndef GL_GENERATE_MIPMAP_SGIS
#define GL_GENERATE_MIPMAP_SGIS 0x8191
#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
#endif
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D 0x806F
#endif
namespace osg {
/** Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.*/
class SG_EXPORT TextureBase : public osg::StateAttribute
{
public :
TextureBase();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
TextureBase(const TextureBase& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual osg::Object* cloneType() const = 0;
virtual osg::Object* clone(const CopyOp& copyop) const = 0;
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const TextureBase *>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "TextureBase"; }
virtual const Type getType() const { return TEXTURE; }
virtual bool isTextureAttribute() const { return true; }
enum WrapParameter {
WRAP_S,
WRAP_T,
WRAP_R
};
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
};
/** Set the texture wrap mode.*/
void setWrap(const WrapParameter which, const WrapMode wrap);
/** Get the texture wrap mode.*/
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; _texParametersDirty = true; }
const Vec4& borderColor(void) const { return _borderColor; }
enum FilterParameter {
MIN_FILTER,
MAG_FILTER
};
enum FilterMode {
LINEAR = GL_LINEAR,
LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR,
LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
NEAREST = GL_NEAREST,
NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST
};
/** 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;
/** Set the maximum anisotropy value, default value is 1.0 for
* no anisotropic filtering. If hardware does not support anisotropic
* filtering then normal filtering is used, equivilant to a max anisotropy value of 1.0.
* valid range is 1.0f upwards. The maximum value depends on the graphics
* system being used.*/
void setMaxAnisotropy(float anis);
/** Get the maximum anisotropy value.*/
inline float getMaxAnisotropy() const { return _maxAnisotropy; }
enum InternalFormatMode {
USE_IMAGE_DATA_FORMAT,
USE_USER_DEFINED_FORMAT,
USE_ARB_COMPRESSION,
USE_S3TC_DXT1_COMPRESSION,
USE_S3TC_DXT3_COMPRESSION,
USE_S3TC_DXT5_COMPRESSION
};
/** Set the internal format mode.
* Note, If the mode is set USE_IMAGE_DATA_FORMAT, USE_ARB_COMPRESSION,
* USE_S3TC_COMPRESSION the internalFormat is automatically selected,
* and will overwrite the previous _internalFormat.
*/
inline void setInternalFormatMode(const InternalFormatMode mode) { _internalFormatMode = mode; }
/** Get the internal format mode.*/
inline const InternalFormatMode getInternalFormatMode() const { return _internalFormatMode; }
/** Set the internal format to use when creating OpenGL textures.
* Also sets the internalFormatMode to USE_USER_DEFINED_FORMAT.
*/
inline void setInternalFormat(const int internalFormat)
{
_internalFormatMode = USE_USER_DEFINED_FORMAT;
_internalFormat = internalFormat;
}
/** Get the internal format to use when creating OpenGL textures.*/
inline const int getInternalFormat() const { if (_internalFormat==0) computeInternalFormat(); return _internalFormat; }
bool isCompressedInternalFormat() const;
/** Get the handle to the texture object for the current context.*/
/** return the OpenGL texture object for specified context.*/
inline GLuint& getTextureObject(const uint contextID) const
{
// pad out handle list if required.
if (_handleList.size()<=contextID)
_handleList.resize(contextID+1,0);
// get the globj for the current contextID.
return _handleList[contextID];
}
inline uint& getModifiedTag(const uint contextID) const
{
// pad out handle list if required.
if (_modifiedTag.size()<=contextID)
_modifiedTag.resize(contextID+1,0);
// get the modified tag for the current contextID.
return _modifiedTag[contextID];
}
/** Force a recompile on next apply() of associated OpenGL texture objects.*/
void dirtyTextureObject();
/** use deleteTextureObject instead of glDeleteTextures to allow
* OpenGL texture objects to cached until they can be deleted
* by the OpenGL context in which they were created, specified
* by contextID.*/
static void deleteTextureObject(uint contextID,GLuint handle);
/** flush all the cached display list which need to be deleted
* in the OpenGL context related to contextID.*/
static void flushDeletedTextureObjects(uint contextID);
/** Get the maximum texture size supported, this is the
normally define by GL_MAX_TEXTURE_SIZE, but can be overridden
by the OSG_MAX_TEXTURE_SIZE environmental variable.*/
static GLint getMaxTextureSize();
/** TextureBase is pure virtual base class, apply must be overriden. */
virtual void apply(State& state) const = 0;
/** Calls apply(state) to compile the texture. */
virtual void compile(State& state) const;
protected :
virtual ~TextureBase();
virtual void computeInternalFormat() const = 0;
void computeInternalFormatWithImage(osg::Image& image) const;
bool isCompressedInternalFormat(GLint internalFormat) const;
/** Helper method which does setting of texture paramters. */
void applyTexParameters(GLenum target, State& state) const;
/** Helper method which does the creation of the texture itself, and
* does not set or use texture binding. */
void applyTexImage2D(GLenum target, Image* image, State& state, GLsizei& width, GLsizei& height,GLsizei& numMimpmapLevels) const;
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
int compareTextureBase(const TextureBase& rhs) const;
typedef std::vector<GLuint> TextureNameList;
mutable TextureNameList _handleList;
typedef std::vector<uint> ImageModifiedTag;
mutable ImageModifiedTag _modifiedTag;
WrapMode _wrap_s;
WrapMode _wrap_t;
WrapMode _wrap_r;
FilterMode _min_filter;
FilterMode _mag_filter;
float _maxAnisotropy;
Vec4 _borderColor;
// true if apply tex parameters required.
mutable bool _texParametersDirty;
InternalFormatMode _internalFormatMode;
mutable GLint _internalFormat;
// static cache of deleted display lists which can only
// by completely deleted once the appropriate OpenGL context
// is set.
typedef std::map<uint,std::set<uint> > DeletedTextureObjectCache;
static DeletedTextureObjectCache s_deletedTextureObjectCache;
};
}
#endif

View File

@@ -7,7 +7,7 @@
#ifndef OSG_TEXTURECUBEMAP
#define OSG_TEXTURECUBEMAP 1
#include <osg/TextureBase>
#include <osg/Texture>
#ifndef GL_TEXTURE_CUBE_MAP
#define GL_TEXTURE_CUBE_MAP 0x8513
@@ -16,7 +16,7 @@
namespace osg {
/** TextureCubeMap state class which encapsulates OpenGl texture cubemap functionality.*/
class SG_EXPORT TextureCubeMap : public TextureBase
class SG_EXPORT TextureCubeMap : public Texture
{
public :

View File

@@ -43,9 +43,6 @@ class SG_EXPORT Transform : public Group
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
Transform(const Transform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
#ifdef USE_DEPRECATED_API
Transform(const Matrix& matix);
#endif
META_Node(osg, Transform);
enum ReferenceFrame
@@ -118,8 +115,6 @@ class SG_EXPORT Transform : public Group
return computeWorldToLocalMatrix(matrix,nv);
}
#ifndef USE_DEPRECATED_API
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
{
if (_referenceFrame==RELATIVE_TO_PARENTS)
@@ -146,47 +141,6 @@ class SG_EXPORT Transform : public Group
}
}
#else
/** Set the transform's matrix.*/
void setMatrix(const Matrix& mat) { (*_deprecated_matrix) = mat; _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
/** Get the transform's matrix. */
inline const Matrix& getMatrix() const { return *_deprecated_matrix; }
/** preMult transform. */
void preMult(const Matrix& mat) { _deprecated_matrix->preMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
/** postMult transform. */
void postMult(const Matrix& mat) { _deprecated_matrix->postMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
{
if (_referenceFrame==RELATIVE_TO_PARENTS)
{
matrix.preMult(*_deprecated_matrix);
}
else // absolute
{
matrix = *_deprecated_matrix;
}
return true;
}
virtual const bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
{
if (_referenceFrame==RELATIVE_TO_PARENTS)
{
matrix.postMult(*_deprecated_inverse);
}
else // absolute
{
matrix = *_deprecated_inverse;
}
return true;
}
#endif
protected :
virtual ~Transform();
@@ -202,21 +156,6 @@ class SG_EXPORT Transform : public Group
ReferenceFrame _referenceFrame;
#ifdef USE_DEPRECATED_API
inline void computeInverse() const
{
if (_deprecated_inverseDirty)
{
_deprecated_inverse->invert(*_deprecated_matrix);
_deprecated_inverseDirty = false;
}
}
ref_ptr<Matrix> _deprecated_matrix;
mutable ref_ptr<Matrix> _deprecated_inverse;
mutable bool _deprecated_inverseDirty;
#endif
};
}

View File

@@ -1,18 +0,0 @@
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSG_TRANSPARENCY
#define OSG_TRANSPARENCY 1
#include <osg/BlendFunc>
namespace osg {
#ifdef USE_DEPRECATED_API
typedef BlendFunc Transparency;
#endif
}
#endif