Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

osg::Texture Class Reference

Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures. More...

Inheritance diagram for osg::Texture:

Inheritance graph
[legend]
List of all members.

Public Types

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
}
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
}
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
}

Public Methods

 Texture ()
 Texture (const Texture &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 Copy constructor using CopyOp to manage deep vs shallow copy.

virtual osg::ObjectcloneType () const=0
 Clone the type of an attribute, with Object* return type.

virtual osg::Objectclone (const CopyOp &copyop) const=0
 Clone an attribute, with Object* return type.

virtual bool isSameKindAs (const osg::Object *obj) const
virtual const char * libraryName () const
 return the name of the attribute's library.

virtual const char * className () const
 return the name of the attribute's class type.

virtual const Type getType () const
 return the Type identifier of the attribute's class type.

virtual bool isTextureAttribute () const
 return true if StateAttribute is a type which controls texturing and needs to be issued w.r.t to specific texture unit.

void setWrap (const WrapParameter which, const WrapMode wrap)
 Set the texture wrap mode.

const WrapMode getWrap (const WrapParameter which) const
 Get the texture wrap mode.

void setBorderColor (const Vec4 &color)
 Sets the border color for this texture.

const Vec4borderColor (void) const
void setFilter (const FilterParameter which, const FilterMode filter)
 Set the texture filter mode.

const FilterMode getFilter (const FilterParameter which) const
 Get the texture filter mode.

void setMaxAnisotropy (float anis)
 Set the maximum anisotropy value, default value is 1.0 for no anisotropic filtering.

float getMaxAnisotropy () const
 Get the maximum anisotropy value.

void setInternalFormatMode (const InternalFormatMode mode)
 Set the internal format mode.

const InternalFormatMode getInternalFormatMode () const
 Get the internal format mode.

void setInternalFormat (const int internalFormat)
 Set the internal format to use when creating OpenGL textures.

const int getInternalFormat () const
 Get the internal format to use when creating OpenGL textures.

bool isCompressedInternalFormat () const
GLuint & getTextureObject (const uint contextID) const
 return the OpenGL texture object for specified context.

uintgetModifiedTag (const uint contextID) const
void dirtyTextureObject ()
 Force a recompile on next apply() of associated OpenGL texture objects.

virtual void apply (State &state) const=0
 Texture is pure virtual base class, apply must be overriden.

virtual void compile (State &state) const
 Calls apply(state) to compile the texture.


Static Public Methods

void deleteTextureObject (uint contextID, GLuint handle)
 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.

void flushDeletedTextureObjects (uint contextID)
 flush all the cached display list which need to be deleted in the OpenGL context related to contextID.

GLint getMaxTextureSize ()
 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.


Protected Types

typedef std::vector< GLuint > TextureNameList
typedef std::vector< uintImageModifiedTag
typedef std::map< uint, std::set<
uint > > 
DeletedTextureObjectCache

Protected Methods

virtual ~Texture ()
virtual void computeInternalFormat () const=0
void computeInternalFormatWithImage (osg::Image &image) const
bool isCompressedInternalFormat (GLint internalFormat) const
void applyTexParameters (GLenum target, State &state) const
 Helper method which does setting of texture paramters.

void applyTexImage2D (GLenum target, Image *image, State &state, GLsizei &width, GLsizei &height, GLsizei &numMimpmapLevels) const
 Helper method which does the creation of the texture itself, and does not set or use texture binding.

int compareTexture (const Texture &rhs) const
 return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.


Protected Attributes

TextureNameList _handleList
ImageModifiedTag _modifiedTag
WrapMode _wrap_s
WrapMode _wrap_t
WrapMode _wrap_r
FilterMode _min_filter
FilterMode _mag_filter
float _maxAnisotropy
Vec4 _borderColor
bool _texParametersDirty
InternalFormatMode _internalFormatMode
GLint _internalFormat

Static Protected Attributes

DeletedTextureObjectCache s_deletedTextureObjectCache

Detailed Description

Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.


Member Typedef Documentation

typedef std::map<uint,std::set<uint> > osg::Texture::DeletedTextureObjectCache [protected]
 

typedef std::vector<uint> osg::Texture::ImageModifiedTag [protected]
 

typedef std::vector<GLuint> osg::Texture::TextureNameList [protected]
 


Member Enumeration Documentation

enum osg::Texture::FilterMode
 

Enumeration values:
LINEAR 
LINEAR_MIPMAP_LINEAR 
LINEAR_MIPMAP_NEAREST 
NEAREST 
NEAREST_MIPMAP_LINEAR 
NEAREST_MIPMAP_NEAREST 

enum osg::Texture::FilterParameter
 

Enumeration values:
MIN_FILTER 
MAG_FILTER 

enum osg::Texture::InternalFormatMode
 

Enumeration values:
USE_IMAGE_DATA_FORMAT 
USE_USER_DEFINED_FORMAT 
USE_ARB_COMPRESSION 
USE_S3TC_DXT1_COMPRESSION 
USE_S3TC_DXT3_COMPRESSION 
USE_S3TC_DXT5_COMPRESSION 

enum osg::Texture::WrapMode
 

Enumeration values:
CLAMP 
CLAMP_TO_EDGE 
CLAMP_TO_BORDER 
REPEAT 
MIRROR 

enum osg::Texture::WrapParameter
 

Enumeration values:
WRAP_S 
WRAP_T 
WRAP_R 


Constructor & Destructor Documentation

osg::Texture::Texture  
 

osg::Texture::Texture const Texture &    text,
const CopyOp   copyop = CopyOp::SHALLOW_COPY
 

Copy constructor using CopyOp to manage deep vs shallow copy.

virtual osg::Texture::~Texture   [protected, virtual]
 


Member Function Documentation

virtual void osg::Texture::apply State   state const [pure virtual]
 

Texture is pure virtual base class, apply must be overriden.

Implements osg::StateAttribute.

Implemented in osg::Texture1D, osg::Texture2D, osg::Texture3D, and osg::TextureCubeMap.

void osg::Texture::applyTexImage2D GLenum    target,
Image   image,
State   state,
GLsizei &    width,
GLsizei &    height,
GLsizei &    numMimpmapLevels
const [protected]
 

Helper method which does the creation of the texture itself, and does not set or use texture binding.

void osg::Texture::applyTexParameters GLenum    target,
State   state
const [protected]
 

Helper method which does setting of texture paramters.

const Vec4& osg::Texture::borderColor void    const [inline]
 

virtual const char* osg::Texture::className   const [inline, virtual]
 

return the name of the attribute's class type.

Reimplemented from osg::StateAttribute.

virtual osg::Object* osg::Texture::clone const CopyOp   copyop const [pure virtual]
 

Clone an attribute, with Object* return type.

Must be defined by derived classes.

Implements osg::StateAttribute.

virtual osg::Object* osg::Texture::cloneType   const [pure virtual]
 

Clone the type of an attribute, with Object* return type.

Must be defined by derived classes.

Implements osg::StateAttribute.

int osg::Texture::compareTexture const Texture &    rhs const [protected]
 

return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.

virtual void osg::Texture::compile State   state const [virtual]
 

Calls apply(state) to compile the texture.

Reimplemented from osg::StateAttribute.

virtual void osg::Texture::computeInternalFormat   const [protected, pure virtual]
 

Implemented in osg::Texture1D, osg::Texture2D, osg::Texture3D, and osg::TextureCubeMap.

void osg::Texture::computeInternalFormatWithImage osg::Image   image const [protected]
 

void osg::Texture::deleteTextureObject uint    contextID,
GLuint    handle
[static]
 

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.

void osg::Texture::dirtyTextureObject  
 

Force a recompile on next apply() of associated OpenGL texture objects.

void osg::Texture::flushDeletedTextureObjects uint    contextID [static]
 

flush all the cached display list which need to be deleted in the OpenGL context related to contextID.

const FilterMode osg::Texture::getFilter const FilterParameter    which const
 

Get the texture filter mode.

const int osg::Texture::getInternalFormat   const [inline]
 

Get the internal format to use when creating OpenGL textures.

const InternalFormatMode osg::Texture::getInternalFormatMode   const [inline]
 

Get the internal format mode.

float osg::Texture::getMaxAnisotropy   const [inline]
 

Get the maximum anisotropy value.

GLint osg::Texture::getMaxTextureSize   [static]
 

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.

uint& osg::Texture::getModifiedTag const uint    contextID const [inline]
 

GLuint& osg::Texture::getTextureObject const uint    contextID const [inline]
 

return the OpenGL texture object for specified context.

virtual const Type osg::Texture::getType   const [inline, virtual]
 

return the Type identifier of the attribute's class type.

Implements osg::StateAttribute.

const WrapMode osg::Texture::getWrap const WrapParameter    which const
 

Get the texture wrap mode.

bool osg::Texture::isCompressedInternalFormat GLint    internalFormat const [protected]
 

bool osg::Texture::isCompressedInternalFormat   const
 

virtual bool osg::Texture::isSameKindAs const osg::Object   obj const [inline, virtual]
 

virtual bool osg::Texture::isTextureAttribute   const [inline, virtual]
 

return true if StateAttribute is a type which controls texturing and needs to be issued w.r.t to specific texture unit.

Reimplemented from osg::StateAttribute.

virtual const char* osg::Texture::libraryName   const [inline, virtual]
 

return the name of the attribute's library.

Reimplemented from osg::StateAttribute.

void osg::Texture::setBorderColor const Vec4   color [inline]
 

Sets the border color for this texture.

Makes difference only if wrap mode is CLAMP_TO_BORDER

void osg::Texture::setFilter const FilterParameter    which,
const FilterMode    filter
 

Set the texture filter mode.

void osg::Texture::setInternalFormat const int    internalFormat [inline]
 

Set the internal format to use when creating OpenGL textures.

Also sets the internalFormatMode to USE_USER_DEFINED_FORMAT.

void osg::Texture::setInternalFormatMode const InternalFormatMode    mode [inline]
 

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 osg::Texture::setMaxAnisotropy float    anis
 

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 osg::Texture::setWrap const WrapParameter    which,
const WrapMode    wrap
 

Set the texture wrap mode.


Member Data Documentation

Vec4 osg::Texture::_borderColor [protected]
 

TextureNameList osg::Texture::_handleList [protected]
 

GLint osg::Texture::_internalFormat [protected]
 

InternalFormatMode osg::Texture::_internalFormatMode [protected]
 

FilterMode osg::Texture::_mag_filter [protected]
 

float osg::Texture::_maxAnisotropy [protected]
 

FilterMode osg::Texture::_min_filter [protected]
 

ImageModifiedTag osg::Texture::_modifiedTag [protected]
 

bool osg::Texture::_texParametersDirty [protected]
 

WrapMode osg::Texture::_wrap_r [protected]
 

WrapMode osg::Texture::_wrap_s [protected]
 

WrapMode osg::Texture::_wrap_t [protected]
 

DeletedTextureObjectCache osg::Texture::s_deletedTextureObjectCache [static, protected]
 


The documentation for this class was generated from the following file:
Generated at Wed Sep 18 13:55:44 2002 for the Open Scene Graph by doxygen 1.2.16.