#include <gfx_opengl_texture2.hh>

Public Types | |
| enum | eForceAlpha { eForceAlpha_FALSE, eForceAlpha_TRUE } |
| enum | { MAX_TEXTURE_WIDTH_BITS = 12 } |
| enum | { MAX_TEXTURE_WIDTH = 1 << (MAX_TEXTURE_WIDTH_BITS-1) } |
| enum | { MAX_TEXTURE_BYTES = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH * 4 } |
Public Member Functions | |
| Texture (void) | |
| Texture (const uint width, const uint height, const eTexelType externalTexelType, const eTexelType internalTexelType) | |
| Texture (const Targa &targa, const eMipmap mipmap=eMipmap_OFF, const eForceAlpha forceAlpha=eForceAlpha_FALSE) | |
| ~Texture () | |
| void | Bind (void) const |
| CLASS_METHOD void | Map (const TexCoord2 &tc) |
| CLASS_METHOD void | Map (fp tx, fp ty) |
| bool | IfValid (void) const |
| uint | GetWidth (void) const |
| uint | GetHeight (void) const |
| uint | DimCnt (void) const |
| uint | GetTexelCnt (void) const |
| uint | GetExternalByteCnt (void) const |
| CLASS_METHOD uint | GetTotalMemoryUsed (void) |
| void | SetTextureImage (const Array< Texel32 > &texels, const eMipmap mipmap=eMipmap_OFF) |
| void | SetTextureImage (const Texel32 *texels, const uint texelCnt, const eMipmap mipmap=eMipmap_OFF) |
| void | SetTextureImage (const uint8 *texels, const uint externalByteCnt, const eMipmap mipmap=eMipmap_OFF) |
| void | SetMinFilter (eMinFilter filter) |
| void | SetMagFilter (eMagFilter filter) |
| void | SetFastestFilters (void) |
| void | SetWrap (eWrap wrap, uint dim) |
| void | SetWrap (eWrap wrap) |
| void | SetFunc (eFunc func) |
Private Member Functions | |
| void | Init (const uint width, const uint height, const eTexelType externalTexelType, const eTexelType internalTexelType) |
| uint | TexelCntToExternalByteCnt (const uint texelCnt) const |
| uint | TexelCntToInternalByteCnt (const uint texelCnt) const |
| uint | GetInternalTexelCnt (void) const |
| uint | GetInternalByteCnt (void) const |
| uint | GetByteCnt_ (const bool hasAlpha) const |
| uint | GetTexelCnt_ (const bool hasAlpha) const |
| uint | TexelCntToByteCnt_ (const uint texelCnt, const uint texelLen) const |
| uint | EstimateInternalByteCnt (const eMipmap mipmap) const |
Private Attributes | |
| Bits | mBits |
| eTexelType | mExternalTexelType |
| GL_GBRA8, GL_RGBA8, etc. | |
| eTexelType | mInternalTexelType |
| not BGR/BGRA | |
| GLuint | mId |
| OpenGL texture object ID. | |
| eFunc | mTexFunc |
| passed to glTexEnv() by Texture::Begin() | |
| CLASS_VAR int | msTotalMemoryUsed |
| total memory used by all textures | |
Friends | |
| bool | operator< (Texture &a, Texture &b) |
Classes | |
| struct | Bits |
///
/// Texture is a mixin class for 2D textures.
///
/// - Clients are the source of texture images.
/// Clients can procedurally-generate or load texture images from files
/// and pass them to Texture::SetTextureImage().
/// - Interface for setting texture modes (filters, blend functions, etc).
/// - Abstracts texel types (BGRA8, RGBA8).
/// - Tracks texture memory usage.
///
/// Invalid textures are useful:
/// ----------------------------
/// The default Texture ctor creates an inexpensive-but-invalid Texture.
/// Invalid Textures are a substitute for NULL pointers.
/// Any client that does construct invalid Textures is responsible
/// for checking Texture::IfValid() before calling a Texture method
/// (else results are UNDEFINED).
///
/// Example of procedural textures:
/// -------------------------------
/// // Creates a Texture object. It has no image yet.
/// shptr<Texture> tex = new Texture( TEXEL_BGRA8, width, height );
///
/// // Generate texture image.
/// // Client allocates and fills the texture image.
/// // Texel32 is a typedef that abstracts BGRA8 or RGBA8 format.
/// const uint texelCnt = tex->GetTexelCnt();
/// Array<Texture::Texel32> texels( texelCnt );
/// for ( uint i = 0; i < texelCnt; i += Texture::TEXEL32_LEN )
/// {
/// // Whether Texel32 is in RGBA8 or BGRA8 order
/// // is abstracted by these #defines.
/// ASSERT( i < texelCnt );
/// Texture::Texel32 texel = (b << Texture::TEXEL32_BB_BIT_SHIFT)
/// | (g << Texture::TEXEL32_GG_BIT_SHIFT)
/// | (r << Texture::TEXEL32_RR_BIT_SHIFT)
/// | (a << Texture::TEXEL32_AA_BIT_SHIFT);
/// texels[i] = texel;
/// }
/// tex->SetTextureImage( texels );
///
///
| gfx::Texture::Texture | ( | void | ) |
Construct an invalid Texture (substitutes for NULL pointer).
| gfx::Texture::Texture | ( | const uint | width, | |
| const uint | height, | |||
| const eTexelType | externalTexelType, | |||
| const eTexelType | internalTexelType | |||
| ) |
| gfx::Texture::Texture | ( | const Targa & | targa, | |
| const eMipmap | mipmap = eMipmap_OFF, |
|||
| const eForceAlpha | forceAlpha = eForceAlpha_FALSE | |||
| ) |
| gfx::Texture::~Texture | ( | ) |
| void gfx::Texture::Bind | ( | void | ) | const [inline] |
Bind texture.
Caller has enabled texturing using GFX::EnableTexture2(true). BTW, to disable texturing, call GFX::EnableTexture2(false).
| CLASS_METHOD void gfx::Texture::Map | ( | const TexCoord2 & | tc | ) | [inline] |
Send 2D texture coordinates to map texture to a polygon. Map are class methods since, being unassociated with a texture object, simplifies code that switches between texture objects.
| bool gfx::Texture::IfValid | ( | void | ) | const [inline] |
Texture info.
| uint gfx::Texture::GetWidth | ( | void | ) | const [inline] |
| uint gfx::Texture::GetHeight | ( | void | ) | const [inline] |
| uint gfx::Texture::DimCnt | ( | void | ) | const [inline] |
| uint gfx::Texture::GetTexelCnt | ( | void | ) | const |
| uint gfx::Texture::GetExternalByteCnt | ( | void | ) | const |
| CLASS_METHOD uint gfx::Texture::GetTotalMemoryUsed | ( | void | ) | [inline] |
| void gfx::Texture::SetTextureImage | ( | const Array< Texel32 > & | texels, | |
| const eMipmap | mipmap = eMipmap_OFF | |||
| ) |
Texture image. GetTextureImage() omitted.
| void gfx::Texture::SetTextureImage | ( | const Texel32 * | texels, | |
| const uint | texelCnt, | |||
| const eMipmap | mipmap = eMipmap_OFF | |||
| ) |
| void gfx::Texture::SetTextureImage | ( | const uint8 * | texels, | |
| const uint | externalByteCnt, | |||
| const eMipmap | mipmap = eMipmap_OFF | |||
| ) |
Load texture image into OpenGL (from raw byte array).
| texels | This class checks that caller used the right count. | |
| externalByteCnt | Count of BYTES in source texture image (external from gfxsys). | |
| mipmap |
| void gfx::Texture::SetMinFilter | ( | eMinFilter | filter | ) |
Texture mode.
Texture modes.
Some OpenGL texture functions affect all texture objects, some affect only the bound one. Thus, since glTexEnv() doesn't affect the bound texture object, Texture::Bind() must call it every time.
http://www.opengl.org/resources/faq/technical/texture.htm The following functions affect the state of a texture object: glTexImage*(), glTexSubImage*(), glCopyTexImage*(), glCopyTexSubImage*(), glTexParameter*(), and glPrioritizeTextures(). Since the GLU routines for building mipmap pyramids ultimately call glTexImage*(), they also affect texture objects. Absent from this list are: glTexEnv*() and glTexGen*() which don't affect a particular texture object.
| void gfx::Texture::SetMagFilter | ( | eMagFilter | filter | ) |
| void gfx::Texture::SetFastestFilters | ( | void | ) |
| void gfx::Texture::SetWrap | ( | eWrap | wrap | ) |
| void gfx::Texture::SetFunc | ( | eFunc | func | ) |
| void gfx::Texture::Init | ( | const uint | width, | |
| const uint | height, | |||
| const eTexelType | externalTexelType, | |||
| const eTexelType | internalTexelType | |||
| ) | [private] |
Misc private methods.
| uint gfx::Texture::GetInternalTexelCnt | ( | void | ) | const [private] |
| uint gfx::Texture::GetInternalByteCnt | ( | void | ) | const [private] |
| uint gfx::Texture::GetByteCnt_ | ( | const bool | hasAlpha | ) | const [private] |
| uint gfx::Texture::GetTexelCnt_ | ( | const bool | hasAlpha | ) | const [private] |
Estimate the amount of memory a texture is ACTIVELY consuming, including mipmaps.
Bits gfx::Texture::mBits [private] |
eTexelType gfx::Texture::mExternalTexelType [private] |
GL_GBRA8, GL_RGBA8, etc.
eTexelType gfx::Texture::mInternalTexelType [private] |
not BGR/BGRA
GLuint gfx::Texture::mId [private] |
OpenGL texture object ID.
eFunc gfx::Texture::mTexFunc [private] |
passed to glTexEnv() by Texture::Begin()
int gfx::Texture::msTotalMemoryUsed [private] |
total memory used by all textures
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:28 2007