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

sglTexture Class Reference

#include <sglTexture.hpp>

Inheritance diagram for sglTexture::

sglTexturingStatelet sglStatelet sglObject sglTexture1D sglTexture2D sglTextureCubeMap List of all members.

Public Types

typedef void (* callback )(sglTexture *)
enum  WrapEnum {
enum  FilterEnum {
enum  ExternalFormatEnum {
  eRGB = GL_RGB,
  eRED = GL_RED,
enum  TypeEnum {
  eINT = GL_INT,
enum  InternalFormatEnum {
  eINT_R3_G3_B2 = GL_R3_G3_B2,
  eINT_RGB4 = GL_RGB4,
  eINT_RGB5_A1 = GL_RGB5_A1,
  eINT_RGB8 = GL_RGB8,
  eINT_RGB10_A2 = GL_RGB10_A2,
  eINT_RGB5 = GL_RGB5,
  eINT_RGB10 = GL_RGB10,
  eINT_RGB12 = GL_RGB12,
  eINT_RGB16 = GL_RGB16,
  eINT_RGBA12 = GL_RGBA12,
enum  CompressionLevelEnum {

Public Methods

virtual ~sglTexture ()
virtual bool setMipmapLevels (const vector< void *> &images)=0
virtual bool replaceImage (void *new_image, GLint level=0)=0
void setInternalFormat (InternalFormatEnum format)
InternalFormatEnum getInternalFormat () const
ExternalFormatEnum getExternalFormat () const
void setCompressionLevel (CompressionLevelEnum fact)
CompressionLevelEnum getCompressionLevel ()
void setLODMinMax (float minLOD, float maxLOD)
void getLODMinMax (float &minLOD, float &maxLOD) const
void setLODBaseLevel (GLuint base)
GLuint getLODBaseLevel () const
void setLODMaxLevel (GLuint maxLevel)
GLuint getLODMaxLevel () const
virtual unsigned int getIdealInternalSize () const=0
virtual unsigned int getLikelyInternalSize () const=0
void setBorderColor (const sglVec4f &color)
void getBorderColor (sglVec4f &color) const
void setMinFilter (FilterEnum filter)
FilterEnum getMinFilter () const
void setMagFilter (FilterEnum filter)
FilterEnum getMagFilter () const
void setMaxAnisotropy (float max)
float getMaxAnisotropy () const
void setAutoMipmapFlag (bool on)
bool getAutoMipmapFlag ()
bool isValid () const
virtual bool checkProxy ()=0
virtual void bind ()=0
void unbind ()
void reset ()
bool isBound () const
void applyToUnit (sglCurrState *, unsigned int) const
virtual bool getSorted () const
void setPreBindCallback (callback func)
callback getPreBindCallback () const
void setPostBindCallback (callback func)
callback getPostBindCallback () const
virtual bool buildMipmaps (vector< void *> &mipmaps)=0
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Static Public Methods

void bindDirtyTextures ()
void setAutoBind (bool on)
bool getAutoBind ()
unsigned int getBitsPerTexel (InternalFormatEnum format)
float getMaxSupportedMaxAnisotropy ()
unsigned int getNumComponents (ExternalFormatEnum external_format)

Protected Types

enum  DirtyEnum {
  eDIRTY_IMAGE = 0x0001,
  eDIRTY_SUBIMAGE = 0x0002,
  eDIRTY_WRAP_S_MODE = 0x0008,
  eDIRTY_WRAP_T_MODE = 0x0010,
  eDIRTY_MIN_FILTER = 0x0040,
  eDIRTY_MAG_FILTER = 0x0080,
  eDIRTY_MIPMAP = 0x0100,
  eDIRTY_REPLACE = 0x0400,
  eDIRTY_LOD = 0x0800,
  eDIRTY_RESET = 0x8000
enum  MipStateEnum {
  eMIP_NONE = 0,
  eMIP_SW = 1,
  eMIP_HW = 2

Protected Methods

 sglTexture (GLenum target)
void dirty (unsigned int mask)
void buildAutoMipmaps (unsigned int mask)

Protected Attributes

const GLenum m_target
unsigned int m_dirty_flag
ExternalFormatEnum m_external_format
void* m_image
bool m_own_image
vector<MipmapStruct> m_mipmaps
GLint m_border
sglVec4f m_border_color
FilterEnum m_mag_filter
FilterEnum m_min_filter
float m_max_anisotropy
TypeEnum m_type
InternalFormatEnum m_internal_format
bool m_internal_format_flag
GLuint m_texture_object
bool m_valid_flag
MipStateEnum m_auto_mipmap_flag
CompressionLevelEnum m_compression_flag
GLenum m_compression_enum
bool m_texture_lod_active
float m_texture_lod_min
float m_texture_lod_max
GLuint m_texture_lod_base_level
GLuint m_texture_lod_max_level
bool m_bound_mipmaps
callback m_pre_bind_callback
callback m_post_bind_callback
unsigned int m_internal_size
bool m_internal_size_dirty

Static Protected Attributes

set<sglTexture *> s_dirty_textures
bool s_auto_bind
sglLock s_lock

Detailed Description

base class container for image data used for texturing (1D, 2D, and someday 3D)

Definition at line 41 of file sglTexture.hpp.

Member Typedef Documentation

typedef void(* sglTexture::callback)(sglTexture *)

Callback function prototype.

Member Enumeration Documentation

enum sglTexture::WrapEnum

Texture wrap modes.

Definition at line 45 of file sglTexture.hpp.

enum sglTexture::FilterEnum

Filters used for minifying or magnifying the texture.

Definition at line 53 of file sglTexture.hpp.

enum sglTexture::ExternalFormatEnum

Valid formats for images used to create textures.

Definition at line 64 of file sglTexture.hpp.

enum sglTexture::TypeEnum

Valid data types for images used to create textures.

Definition at line 77 of file sglTexture.hpp.

enum sglTexture::InternalFormatEnum

Possible storage formats for textures in internal display memory.

Definition at line 90 of file sglTexture.hpp.

Constructor & Destructor Documentation

sglTexture::~sglTexture ( ) [virtual]


sglTexture::sglTexture ( GLenum target ) [protected]

Constructor: target = one of GL_TEXTURE_1D or GL_TEXTURE_2D

Member Function Documentation

void sglTexture::bindDirtyTextures ( ) [static]

Bind all textures that are currently dirty. Note that if (getAutoBind() == false), this method does nothing. This method is called by sglScene::preDraw().

void sglTexture::setAutoBind ( bool on ) [static]

Enables/Disables the bindDirtyTextures() method. default: true (dirty textures will automatically be bound by bindDirtyTextures())

bool sglTexture::getAutoBind ( ) [static]

Returns true if bindDirtyTextures() is enabled.

unsigned int sglTexture::getBitsPerTexel ( InternalFormatEnum format ) [static]

Returns the ideal number of bits per texel used for the given internal texture format.

bool sglTexture::setMipmapLevels ( const vector< void *> & images ) [pure virtual]

Set the mipmap images. Returns false if number of images is not correct or if the AutoMipmap feature is on. Assumes that the images are correct in size and format.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

bool sglTexture::replaceImage ( void * new_image,
GLint level = 0 ) [pure virtual]

Helper function to replace an entire image via subtexload funtionality. A previous image must first have been set with the setImage or setMipmapLevels methods. The new_image data must be the same size as the original image, and the pointer to the old image data is lost. The level parameter specifies which mipmap level to replace.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

void sglTexture::setInternalFormat ( InternalFormatEnum format )

Request textures to be stored with the given format in internal texture memory. Note: this only a request and is not guaranteed. default: automatically determined during call to setImage

InternalFormatEnum sglTexture::getInternalFormat ( ) const [inline]

Returns the requested internal texture format.

Definition at line 185 of file sglTexture.hpp.

ExternalFormatEnum sglTexture::getExternalFormat ( ) const [inline]

Returns the current external texture format.

Definition at line 188 of file sglTexture.hpp.

void sglTexture::setCompressionLevel ( CompressionLevelEnum fact )

Sets the requested compression format

CompressionLevelEnum sglTexture::getCompressionLevel ( ) [inline]

returns the requested compression format

Definition at line 194 of file sglTexture.hpp.

void sglTexture::setLODMinMax ( float minLOD,
float maxLOD )

Sets the min/max lod to use for this texture

void sglTexture::setLODBaseLevel ( GLuint base )

sets the "base" level to BASE instead of zero

void sglTexture::setLODMaxLevel ( GLuint maxLevel )

sets the "max" level to maxLevel instead of funtion of "base" size

unsigned int sglTexture::getIdealInternalSize ( ) const [pure virtual]

Returns the number of bytes of texture memory this texture will use if the requested internal format was honored.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

unsigned int sglTexture::getLikelyInternalSize ( ) const [pure virtual]

Returns the number of bytes of texture memory this texture is most likely using. Must be called by a thread with a current rendering context.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

void sglTexture::setBorderColor ( const sglVec4f & color )

Set the color to use past the edge of a texture when CLAMP is used. default: (1.0, 1.0, 1.0, 1.0)

void sglTexture::getBorderColor ( sglVec4f & color ) const [inline]

Get the color to use past the edge of a texture when CLAMP is used.

Definition at line 228 of file sglTexture.hpp.

void sglTexture::setMinFilter ( FilterEnum filter )

Set the filter to use for texture minification. default: eLINEAR

FilterEnum sglTexture::getMinFilter ( ) const [inline]

Returns the filter to use for texture minification.

Definition at line 236 of file sglTexture.hpp.

void sglTexture::setMagFilter ( FilterEnum filter )

Set the filter to use for texture magnification. default: eLINEAR

FilterEnum sglTexture::getMagFilter ( ) const [inline]

Returns the filter to use for texture magnification.

Definition at line 244 of file sglTexture.hpp.

void sglTexture::setMaxAnisotropy ( float max )

Get/set the maximum degree of anisotropy to account for in texture filtering (if supported). A value of 1.0f disables anisotropic filtering. default: 1.0f

Reimplemented in sglTextureCubeMap.

float sglTexture::getMaxSupportedMaxAnisotropy ( ) [inline, static]

Get the maximum max-anisotropy supported on this system. Returns 1.0f if anisotropic filtering is not supported.

Reimplemented in sglTextureCubeMap.

Definition at line 258 of file sglTexture.hpp.

void sglTexture::setAutoMipmapFlag ( bool on )

Enable/Disable the automatic generation of mipmaps. default: false

bool sglTexture::getAutoMipmapFlag ( ) [inline]

Returns true if automatic mipmap generation is on.

Definition at line 267 of file sglTexture.hpp.

bool sglTexture::isValid ( ) const [inline]

Return status of this object (as a valid texture). if (isValid() == false) texturing will be disabled

Definition at line 272 of file sglTexture.hpp.

bool sglTexture::checkProxy ( ) [pure virtual]

Use the GL_PROXY_TEXTURE mechanism to check if the texture is capable of being loaded into texture memory. Returns false if the texture is too large. Must be called by a thread with a current rendering context.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

void sglTexture::bind ( ) [pure virtual]

Copy texture (and changes) into texture memory. If (getAutoBind() == false), this method must be called before before the texture can be applied. Must be called by a thread with a current rendering context.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

void sglTexture::unbind ( )

Removes the texture from texture memory.

void sglTexture::reset ( )

Dirties the texture, such that during the next bind the texture will be completely recreated in texture memory. This may be useful if the texture had mipmaps defined, but they are no longer needed.

bool sglTexture::isBound ( ) const [inline]

Returns true if the texture is ready to be rendered.

Definition at line 298 of file sglTexture.hpp.

void sglTexture::applyToUnit ( sglCurrState * curr_state,
unsigned int unit ) const [virtual]

Apply this state change to the current rendering state. NOTE: bind() should be called before calling apply().

Reimplemented from sglTexturingStatelet.

bool sglTexture::getSorted ( ) const [inline, virtual]

Returns true if this type of statelet should be sorted by pointer rather than indexed into an array.

Reimplemented from sglStatelet.

Definition at line 308 of file sglTexture.hpp.

void sglTexture::setPreBindCallback ( callback func )

Set the callback function to call before this texture is bound. This could be used to setup state like glPixelTransfer. default: NULL

callback sglTexture::getPreBindCallback ( ) const [inline]

Returns the callback function to call before this texture is bound.

Definition at line 320 of file sglTexture.hpp.

void sglTexture::setPostBindCallback ( callback func )

Set the callback function to call after this texture is bound. This should be used to revert any state changes made by the function registered in setPreBindCallback. default: NULL

callback sglTexture::getPostBindCallback ( ) const [inline]

Returns the callback function to call after this texture is bound.

Definition at line 330 of file sglTexture.hpp.

unsigned int sglTexture::getNumComponents ( ExternalFormatEnum external_format ) [static]

Returns the number of color components in the given external format.

bool sglTexture::buildMipmaps ( vector< void *> & mipmaps ) [pure virtual]

Generates a set of mipmaps from the level 0 image in this texture. Existing images in the given mipmaps vector will be resized (via realloc) and excess images will be free()'d. Returns false if the mipmaps could not be built.

Reimplemented in sglTexture1D, sglTexture2D, and sglTextureCubeMap.

virtual void sglTexture::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglStatelet.

Reimplemented in sglTexture1D, and sglTexture2D.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:10 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001