#include <CTexture2D.h>
Public Member Functions | |
cTexture2D () | |
Constructor of cTexture2D. | |
~cTexture2D () | |
Destructor of cTexture2D. | |
bool | loadFromFile (const char *a_fileName) |
Load an image file (CHAI currently supports 24-bit .bmp and 32-bit .tga files). | |
void | render () |
Enable texturing and set this texture as the current texture. | |
void | markForUpdate () |
Call this to force texture re-initialization. | |
void | setEnvironmentMode (const GLint &a_environmentMode) |
Set the environment mode (GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE, or -1 for "don't set"). | |
GLint | getEnvironmentMode () |
Get the environment mode status. | |
void | setWrapMode (const GLint &a_wrapSmode, const GLint &a_wrapTmode) |
Set the texture wrap mode. | |
GLint | getWrapSmode () |
Get the texture wrap mode of S. | |
GLint | getWrapTmode () |
Get the texture wrap mode of T. | |
void | setMagnificationFunction (GLint a_magnificationFunction) |
set the magnification function | |
GLint | getMagnificationFunction () |
get current magnification function | |
void | setMinifyingFunction (GLint a_minifyingFunction) |
set the minification function | |
GLint | getMinifyingFunction () |
get current magnification function | |
void | setSphericalMappingEnabled (bool a_enabled) |
set spherical mapping mode ON or OFF | |
Public Attributes | |
cImageLoader | m_image |
Image loader (use this to get data about the texture itself). | |
cColorf | m_color |
Environmental color. | |
Private Member Functions | |
void | reset () |
Reset internal variables. This function should be called only by constructors. | |
void | update () |
Initialize GL texture. | |
Private Attributes | |
bool | m_updateTextureFlag |
If true, texture bitmap has not yet been sent to video card. | |
GLuint | m_textureID |
OpenGL texture ID number. | |
GLint | m_wrapSmode |
texture wrap parameter along S and T (GL_REPEAT or GL_CLAMP) | |
GLint | m_magnificationFunction |
texture magnification function. (GL_NEAREST or GL_LINEAR) | |
GLint | m_minifyingFunction |
texture minifying function. (GL_NEAREST or GL_LINEAR) | |
bool | m_useMipmaps |
If true, we use GLU to build mipmaps. | |
bool | m_useSphericalMapping |
If true, we use spherical mapping. | |
GLint | m_environmentMode |
OpenGL texture mode (GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE). |
cTexture2D::cTexture2D | ( | ) |
Constructor of cTexture2D.
A texture contains a 2D bitmap which can be projected onto the polygons of a 3D solid.
cTexture2D::~cTexture2D | ( | ) |
Destructor of cTexture2D.
Destructor of cTexture2D.
bool cTexture2D::loadFromFile | ( | const char * | a_fileName | ) |
Load an image file (CHAI currently supports 24-bit .bmp and 32-bit .tga files).
Load an image file (CHAI currently supports 24-bit .bmp and 32-bit .tga files on all platforms and should support all formats on Windows)
void cTexture2D::render | ( | ) |
Enable texturing and set this texture as the current texture.
Enable texturing and set this texture as the current texture
void cTexture2D::setWrapMode | ( | const GLint & | a_wrapSmode, | |
const GLint & | a_wrapTmode | |||
) |
Set the texture wrap mode.
Sets the wrap parameter for texture coordinate s to either GL_CLAMP or GL_REPEAT. GL_CLAMP causes s coordinates to be clamped to the range [0,1] and is useful for preventing wrapping artifacts when mapping a single image onto an object. GL_REPEAT causes the integer part of the s coordinate to be ignored; OpenGL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to GL_CLAMP. Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT.
a_wrapSmode | value shall be either GL_REPEAT or GL_CLAMP | |
a_wrapTmode | value shall be either GL_REPEAT or GL_CLAMP |
void cTexture2D::setMagnificationFunction | ( | GLint | a_magnificationFunction | ) |
set the magnification function
The texture magnification function is used when the pixel being textured maps to an area less than or equal to one texture element. It sets the texture magnification function to either GL_NEAREST or GL_LINEAR.
a_magnificationFunction | value shall be either GL_NEAREST or GL_LINEAR. |
void cTexture2D::setMinifyingFunction | ( | GLint | a_minifyingFunction | ) |
set the minification function
The texture minifying function is used whenever the pixel being textured maps to an area greater than one texture element. There are six defined minifying functions. Two of them use the nearest one or nearest four texture elements to compute the texture value. The other four use mipmaps. A mipmap is an ordered set of arrays representing the same image at progressively lower resolutions. If the texture has dimensions 2nx2m there are max(n, m) + 1 mipmaps. The first mipmap is the original texture, with dimensions 2nx2m. Each subsequent mipmap has dimensions 2k1x2l1 where 2 kx2l are the dimensions of the previous mipmap, until either k = 0 or l = 0. At that point, subsequent mipmaps have dimension 1x2l1 or 2k1x1 until the final mipmap, which has dimension 1x1. Mipmaps are defined using glTexImage1D or glTexImage2D with the level-of-detail argument indicating the order of the mipmaps. Level 0 is the original texture; level bold max(n, m) is the final 1x1 mipmap.
a_minifyingFunction | value shall be either GL_NEAREST or GL_LINEAR. |
void cTexture2D::reset | ( | ) | [private] |
Reset internal variables. This function should be called only by constructors.
Reset internal variables. This function should be called only by constructors.
void cTexture2D::update | ( | ) | [private] |
Initialize GL texture.
Generate texture from memory data, to prepare for rendering.