holds texture parameters and contains functions to load texture from external file Textures are connected to shaders via uniform variables More...
#include <texture.h>
Public Member Functions | |
Texture () | |
reset basic values (null name and texture data) | |
~Texture () | |
free all texture data by detaching texture | |
void | SetName (string name) |
set texture name | |
string | GetName () |
get texture name | |
GLint | Load (const char *_texname, int _textype, const char *filename, int _texmode, GLfloat _intensity, GLfloat _tileX, GLfloat _tileY, bool mipmap, bool aniso, GLint cache) |
load TGA texture as texture image. If texture has been loaded, a texture pointer from cache is used instead of reloading from file | |
GLint | Load (const char *_texname, int _textype, const char **cube_files, int _texmode, GLfloat _intensity, GLfloat _tileX, GLfloat _tileY, bool aniso, GLint cache) |
load 6 TGA texture as cube map. If texture has been loaded, a texture pointer from cache is used instead of reloading from file | |
bool | LoadTGA (const char *filename) |
load and decode TGA image from file | |
bool | Empty () |
do we have image data? | |
void | ActivateTexture (GLint tex_unit, bool set_uniforms=false) |
Activates texture map for use by shader. | |
void | GetUniforms (GLuint shader) |
Gets uniform variables froms shader. | |
void | SetShadowMatrix (TMatrix t) |
set texture matrix for shadow map projection | |
void | SetIntensity (GLfloat _intensity) |
set texture intensity | |
void | SetID (GLuint id) |
Set texture ID. | |
void | SetType (int type) |
Set texture type. | |
GLuint | GetID () |
Get OpenGL texture ID. | |
int | GetType () |
Get texture type. | |
int | GetMode () |
Get texture mode. | |
bool | HasTiles () |
Has texture tiles? | |
Public Attributes | |
GLfloat | intensity |
texture intensity |
holds texture parameters and contains functions to load texture from external file Textures are connected to shaders via uniform variables
Texture::~Texture | ( | ) |
free all texture data by detaching texture
void Texture::ActivateTexture | ( | GLint | tex_unit, | |
bool | set_uniforms = false | |||
) |
Activates texture map for use by shader.
tex_unit | multitexture unit used for texture application | |
set_uniforms | shall we also set uniform locations to shader? |
1. set uniform values in shader (tiles, texture unit, texture matrix and intensity)
2. activate and bind texture
void Texture::GetUniforms | ( | GLuint | shader | ) |
Gets uniform variables froms shader.
shader | handle to shader to bound with texture |
1. to avoid mismatch variable names, use texture name as variable prefix
2. get uniforms location
GLint Texture::Load | ( | const char * | _texname, | |
int | _textype, | |||
const char ** | cube_files, | |||
int | _texmode, | |||
GLfloat | _intensity, | |||
GLfloat | _tileX, | |||
GLfloat | _tileY, | |||
bool | aniso, | |||
GLint | cache | |||
) |
load 6 TGA texture as cube map. If texture has been loaded, a texture pointer from cache is used instead of reloading from file
_texname | texture name | |
_textype | texture type (can be BASE,ENV,BUMP) | |
cube_files | array of strings with filenames containing every side of cube map (.tga) | |
_texmode | texture addition mode (can be ADD,MODULATE,DECAL,BLEND) | |
_intensity | texture color intensity (or bump intensity) | |
_tileX | count of horizontal tiles | |
_tileY | count of vertical tiles | |
aniso | should we use anisotropic filtering? | |
cache | whether we should use cached texture image or load new |
if texture is loaded in cache, copy only pointer to texture data
GLint Texture::Load | ( | const char * | _texname, | |
int | _textype, | |||
const char * | filename, | |||
int | _texmode, | |||
GLfloat | _intensity, | |||
GLfloat | _tileX, | |||
GLfloat | _tileY, | |||
bool | mipmap, | |||
bool | aniso, | |||
GLint | cache | |||
) |
load TGA texture as texture image. If texture has been loaded, a texture pointer from cache is used instead of reloading from file
_texname | texture name | |
_textype | texture type (can be BASE,ENV,BUMP) | |
filename | external texture file (.tga) | |
_texmode | texture addition mode (can be ADD,MODULATE,DECAL,BLEND) | |
_intensity | texture color intensity (or bump intensity) | |
_tileX | count of horizontal tiles | |
_tileY | count of vertical tiles | |
mipmap | sholud we generate mipmaps for texture? | |
aniso | should we use anisotropic filtering? | |
cache | whether we should use cached texture image or load new |
if texture is loaded in cache, copy only pointer to texture data
bool Texture::LoadTGA | ( | const char * | filename | ) |
load and decode TGA image from file
filename | file with image data |
read and check file header
find out from image, whether data are compressed or not
extract width, height and bpp of image
allocate memory for image data
load from file according to compression
uncompressed image - read data directly from file
compressed image - decode using RLE compression