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

Teddy::Graphics::Texture Class Reference

Texture. More...

#include <Texture.h>

Inheritance diagram for Teddy::Graphics::Texture:

Inheritance graph
[legend]
Collaboration diagram for Teddy::Graphics::Texture:

Collaboration graph
[legend]
List of all members.

Public Methods

 Texture (const std::string &name)
 Texture constructor. More...

virtual ~Texture ()
 Texture destructor. More...

void putData (unsigned char *data, const Teddy::Maths::IntVector2 &size, int format, unsigned long modify)
void apply ()
 Apply texture to OpenGL state. More...

bool isGood ()
 Return true if there is actual texturemap bind to this texture. More...

const Teddy::Maths::IntVector2 & getSize ()
 Return the size of this Texture in texels. More...

void setWrap (int wrap_s, int wrap_t)
 Set texture repeat parameters. More...

void setEnv (int env)
 Set Texture function. More...

void setEnv (int env, const Color &c)
 Set Texture function. More...

void setFilter (int filter)
 Set Texture filter. More...

bool doFormat ()
 Determine the final image data format for Texture. More...

bool doSize ()
 Determine the final size for Texture image data. More...

bool doBind ()
 Bind the image data to texture. More...

void setWorkData (void *data, bool alloc=true)
 Set working data for Texture. More...

void convert_to_a ()
 Convert Texture working image data to alpha-only format. More...

void convert_to_rgb ()
 Convert Texture working image data to red-green-blue format. More...

void convert_rgba ()
void convert_rgb_to_a ()
 Convert Texture working image data from red-green-blue format to alpha format; alpha == red. More...

void convert_rgba_to_a ()
 Convert Texture working image data from red-green-blue-alpha to alpha format. More...

void convert_a_to_rgb ()
 Convert Texture working image data from alpha format to red-green-blue format (greyscale). More...

void convert_rgba_to_rgb ()
 Convert Texture working image data from red-green-blue-alpha to red-green-blue format. More...

void convert_rgb_to_rgba ()

Static Public Attributes

const unsigned long TX_RESERVED = (1ul<<0ul)
const unsigned long TX_BLIT_NO_SCALE = (1ul<<1ul)
const unsigned long TX_GENERATE_ALPHA = (1ul<<2ul)
const unsigned long TX_ALPHA_ONLY = (1ul<<3ul)
const unsigned long TX_NO_ALPHA = (1ul<<4ul)
const unsigned long WRAP_REPEAT = 1
const unsigned long WRAP_CLAMP = 2
const unsigned long ENV_BLEND = 1
const unsigned long ENV_REPLACE = 2
const unsigned long ENV_DECAL = 3
const unsigned long ENV_MODULATE = 4
const unsigned long FORMAT_INTENSITY = 1
const unsigned long FORMAT_LUMINANCE = 2
const unsigned long FORMAT_LUMINANCE_ALPHA = 3
const unsigned long FORMAT_ALPHA = 4
const unsigned long FORMAT_RGB = 5
const unsigned long FORMAT_RGBA = 6
const unsigned long FILTER_NEAREST = 1
const unsigned long FILTER_LINEAR = 2

Protected Attributes

unsigned char * work_data
 Current working image data for Texture. More...

int work_data_pixel_format
 Working image format. More...

bool work_data_allocated
 Flag true if work_data was internally allocated. More...

bool is_good
 If true, the texture is ready to be used. More...

Teddy::Maths::IntVector2 size
int wrap_s
 Texture s-axis wrap mode. More...

int wrap_t
 Texture t-axis wrap mode. More...

int filter_mode
 Texture filter mode. More...

int env_function
 Texture function. More...

Color env_color
 Color for Texture function. More...

Teddy::MixIn::Options modify
 Allowed and requested image modifications. More...

int gl_internal_format
 OpenGL image data format. More...

GLuint gl_texture_id
 OpenGL Texture id. More...


Detailed Description

Texture.

Definition at line 41 of file Texture.h.


Constructor & Destructor Documentation

Teddy::Graphics::Texture::Texture const std::string &    name
 

Texture constructor.

Parameters:
name  Name for the new Texture

Definition at line 81 of file Texture.cpp.

References env_color, ENV_DECAL, env_function, ENV_MODULATE, filter_mode, FILTER_NEAREST, gl_internal_format, gl_texture_id, is_good, modify, Teddy::MixIn::Options::options, work_data, work_data_allocated, work_data_pixel_format, WRAP_REPEAT, wrap_s, and wrap_t.

Teddy::Graphics::Texture::~Texture   [virtual]
 

Texture destructor.

Definition at line 107 of file Texture.cpp.

References gl_texture_id, and setWorkData.


Member Function Documentation

void Teddy::Graphics::Texture::apply  
 

Apply texture to OpenGL state.

Definition at line 114 of file Texture.cpp.

References Teddy::SysSupport::emsg, gl_texture_id, and Teddy::SysSupport::M_MAT.

void Teddy::Graphics::Texture::convert_a_to_rgb  
 

Convert Texture working image data from alpha format to red-green-blue format (greyscale).

Definition at line 70 of file TextureConversions.cpp.

References setWorkData, size, and work_data.

Referenced by convert_to_rgb.

void Teddy::Graphics::Texture::convert_rgb_to_a  
 

Convert Texture working image data from red-green-blue format to alpha format; alpha == red.

Definition at line 91 of file TextureConversions.cpp.

References setWorkData, size, and work_data.

Referenced by convert_to_a.

void Teddy::Graphics::Texture::convert_rgb_to_rgba  
 

void Teddy::Graphics::Texture::convert_rgba  
 

void Teddy::Graphics::Texture::convert_rgba_to_a  
 

Convert Texture working image data from red-green-blue-alpha to alpha format.

Definition at line 116 of file TextureConversions.cpp.

References setWorkData, size, and work_data.

Referenced by convert_to_a.

void Teddy::Graphics::Texture::convert_rgba_to_rgb  
 

Convert Texture working image data from red-green-blue-alpha to red-green-blue format.

Definition at line 141 of file TextureConversions.cpp.

References setWorkData, size, and work_data.

Referenced by convert_to_rgb.

void Teddy::Graphics::Texture::convert_to_a  
 

Convert Texture working image data to alpha-only format.

Definition at line 35 of file TextureConversions.cpp.

References convert_rgb_to_a, convert_rgba_to_a, and work_data_pixel_format.

Referenced by doFormat.

void Teddy::Graphics::Texture::convert_to_rgb  
 

Convert Texture working image data to red-green-blue format.

Definition at line 47 of file TextureConversions.cpp.

References convert_a_to_rgb, convert_rgba_to_rgb, and work_data_pixel_format.

Referenced by doFormat.

bool Teddy::Graphics::Texture::doBind  
 

Bind the image data to texture.

Definition at line 383 of file Texture.cpp.

References Teddy::SysSupport::emsg, ENV_BLEND, env_color, ENV_DECAL, ENV_MODULATE, ENV_REPLACE, FILTER_LINEAR, FILTER_NEAREST, gl_internal_format, gl_texture_id, glu_Build2DMipmaps, is_good, Teddy::MixIn::Options::isEnabled, Teddy::SysSupport::M_MAT, modify, size, TX_BLIT_NO_SCALE, work_data, work_data_pixel_format, WRAP_CLAMP, and WRAP_REPEAT.

bool Teddy::Graphics::Texture::doFormat  
 

Determine the final image data format for Texture.

Definition at line 241 of file Texture.cpp.

References convert_to_a, convert_to_rgb, Teddy::SysSupport::emsg, gl_internal_format, Teddy::MixIn::Options::isEnabled, Teddy::SysSupport::M_MAT, modify, TX_ALPHA_ONLY, TX_GENERATE_ALPHA, TX_NO_ALPHA, and work_data_pixel_format.

bool Teddy::Graphics::Texture::doSize  
 

Determine the final size for Texture image data.

Definition at line 276 of file Texture.cpp.

References Teddy::SysSupport::emsg, gl_internal_format, glu_ScaleImage, IntVector2, Teddy::SysSupport::M_MAT, Teddy::Graphics::minPow, setWorkData, size, work_data, and work_data_pixel_format.

const IntVector2 & Teddy::Graphics::Texture::getSize  
 

Return the size of this Texture in texels.

Returns:
The size of this Texture in texels

Definition at line 179 of file Texture.cpp.

References IntVector2, and size.

bool Teddy::Graphics::Texture::isGood  
 

Return true if there is actual texturemap bind to this texture.

Returns:
True if this texture has been properly set, false if texture is not ready to be used

Definition at line 128 of file Texture.cpp.

References is_good.

void Teddy::Graphics::Texture::putData unsigned char *    data,
const Teddy::Maths::IntVector2 &    size,
int    format,
unsigned long    modify
 

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.

void Teddy::Graphics::Texture::setEnv int    env_function,
const Color   env_color
 

Set Texture function.

Parameters:
env  Texture function. One of ENV_BLEND, ENV_REPLACE, ENV_DECAL, or ENV_MODULATE.
c  Color to be used by the Texture function

Definition at line 158 of file Texture.cpp.

References env_color, and env_function.

void Teddy::Graphics::Texture::setEnv int    env_function
 

Set Texture function.

Parameters:
env  Texture function. One of ENV_BLEND, ENV_REPLACE, ENV_DECAL, or ENV_MODULATE.

Definition at line 148 of file Texture.cpp.

References env_function.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.

void Teddy::Graphics::Texture::setFilter int    filter_mode
 

Set Texture filter.

Parameters:
filter  The filter mode, either FILTER_NEAREST or FILTER_LINEAR

Definition at line 170 of file Texture.cpp.

References filter_mode.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.

void Teddy::Graphics::Texture::setWorkData void *    vdata,
bool    alloc = true
 

Set working data for Texture.

Parameters:
data  Pointer to working data
The putData() -method puts texture data into texture in several phases. Each phase may modify the existing image data. The currently active image data is kept in work_data pointer. The work_data pointer should be updated through this method.

Definition at line 224 of file Texture.cpp.

References work_data, and work_data_allocated.

Referenced by convert_a_to_rgb, convert_rgb_to_a, convert_rgba_to_a, convert_rgba_to_rgb, doSize, and ~Texture.

void Teddy::Graphics::Texture::setWrap int    wrap_s,
int    wrap_t
 

Set texture repeat parameters.

Parameters:
wrap_s  Wrapping mode for texture s-axis, either WRAP_REPEAT or WRAP_CLAMP
wrap_t  Wrapping mode for texture t-axis, either WRAP_REPEAT or WRAP_CLAMP

Definition at line 138 of file Texture.cpp.

References wrap_s, and wrap_t.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.


Member Data Documentation

const unsigned long Teddy::Graphics::Texture::ENV_BLEND = 1 [static]
 

Definition at line 48 of file Texture.cpp.

Referenced by doBind.

Color Teddy::Graphics::Texture::env_color [protected]
 

Color for Texture function.

Definition at line 108 of file Texture.h.

Referenced by doBind, setEnv, and Texture.

const unsigned long Teddy::Graphics::Texture::ENV_DECAL = 3 [static]
 

Definition at line 50 of file Texture.cpp.

Referenced by doBind, and Texture.

int Teddy::Graphics::Texture::env_function [protected]
 

Texture function.

Definition at line 107 of file Texture.h.

Referenced by setEnv, and Texture.

const unsigned long Teddy::Graphics::Texture::ENV_MODULATE = 4 [static]
 

Definition at line 51 of file Texture.cpp.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface, doBind, and Texture.

const unsigned long Teddy::Graphics::Texture::ENV_REPLACE = 2 [static]
 

Definition at line 49 of file Texture.cpp.

Referenced by doBind.

const unsigned long Teddy::Graphics::Texture::FILTER_LINEAR = 2 [static]
 

Definition at line 61 of file Texture.cpp.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface, and doBind.

int Teddy::Graphics::Texture::filter_mode [protected]
 

Texture filter mode.

Definition at line 106 of file Texture.h.

Referenced by setFilter, and Texture.

const unsigned long Teddy::Graphics::Texture::FILTER_NEAREST = 1 [static]
 

Definition at line 60 of file Texture.cpp.

Referenced by doBind, and Texture.

const unsigned long Teddy::Graphics::Texture::FORMAT_ALPHA = 4 [static]
 

Definition at line 56 of file Texture.cpp.

const unsigned long Teddy::Graphics::Texture::FORMAT_INTENSITY = 1 [static]
 

Definition at line 53 of file Texture.cpp.

const unsigned long Teddy::Graphics::Texture::FORMAT_LUMINANCE = 2 [static]
 

Definition at line 54 of file Texture.cpp.

const unsigned long Teddy::Graphics::Texture::FORMAT_LUMINANCE_ALPHA = 3 [static]
 

Definition at line 55 of file Texture.cpp.

const unsigned long Teddy::Graphics::Texture::FORMAT_RGB = 5 [static]
 

Definition at line 57 of file Texture.cpp.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.

const unsigned long Teddy::Graphics::Texture::FORMAT_RGBA = 6 [static]
 

Definition at line 58 of file Texture.cpp.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface.

int Teddy::Graphics::Texture::gl_internal_format [protected]
 

OpenGL image data format.

Definition at line 110 of file Texture.h.

Referenced by doBind, doFormat, doSize, and Texture.

GLuint Teddy::Graphics::Texture::gl_texture_id [protected]
 

OpenGL Texture id.

Definition at line 111 of file Texture.h.

Referenced by apply, doBind, Teddy::Graphics::PixFileTexture::PixFileTexture, Texture, and ~Texture.

bool Teddy::Graphics::Texture::is_good [protected]
 

If true, the texture is ready to be used.

Definition at line 102 of file Texture.h.

Referenced by doBind, Teddy::Graphics::ImageFileTexture::ImageFileTexture, isGood, Teddy::Graphics::PixFileTexture::PixFileTexture, and Texture.

Teddy::MixIn::Options Teddy::Graphics::Texture::modify [protected]
 

Allowed and requested image modifications.

Definition at line 109 of file Texture.h.

Referenced by doBind, doFormat, and Texture.

Teddy::Maths::IntVector2 Teddy::Graphics::Texture::size [protected]
 

Definition at line 103 of file Texture.h.

Referenced by convert_a_to_rgb, convert_rgb_to_a, convert_rgba_to_a, convert_rgba_to_rgb, Teddy::Graphics::ImageFileTexture::copySdlSurface, doBind, doSize, getSize, and Teddy::Graphics::PixFileTexture::PixFileTexture.

const unsigned long Teddy::Graphics::Texture::TX_ALPHA_ONLY = (1ul<<3ul) [static]
 

Definition at line 42 of file Texture.cpp.

Referenced by doFormat.

const unsigned long Teddy::Graphics::Texture::TX_BLIT_NO_SCALE = (1ul<<1ul) [static]
 

Definition at line 40 of file Texture.cpp.

Referenced by doBind.

const unsigned long Teddy::Graphics::Texture::TX_GENERATE_ALPHA = (1ul<<2ul) [static]
 

Definition at line 41 of file Texture.cpp.

Referenced by doFormat.

const unsigned long Teddy::Graphics::Texture::TX_NO_ALPHA = (1ul<<4ul) [static]
 

Definition at line 43 of file Texture.cpp.

Referenced by doFormat.

const unsigned long Teddy::Graphics::Texture::TX_RESERVED = (1ul<<0ul) [static]
 

Definition at line 39 of file Texture.cpp.

unsigned char* Teddy::Graphics::Texture::work_data [protected]
 

Current working image data for Texture.

Definition at line 99 of file Texture.h.

Referenced by convert_a_to_rgb, convert_rgb_to_a, convert_rgba_to_a, convert_rgba_to_rgb, doBind, doSize, setWorkData, and Texture.

bool Teddy::Graphics::Texture::work_data_allocated [protected]
 

Flag true if work_data was internally allocated.

Definition at line 101 of file Texture.h.

Referenced by setWorkData, and Texture.

int Teddy::Graphics::Texture::work_data_pixel_format [protected]
 

Working image format.

Definition at line 100 of file Texture.h.

Referenced by convert_to_a, convert_to_rgb, doBind, doFormat, doSize, and Texture.

const unsigned long Teddy::Graphics::Texture::WRAP_CLAMP = 2 [static]
 

Definition at line 46 of file Texture.cpp.

Referenced by doBind.

const unsigned long Teddy::Graphics::Texture::WRAP_REPEAT = 1 [static]
 

Definition at line 45 of file Texture.cpp.

Referenced by Teddy::Graphics::ImageFileTexture::copySdlSurface, doBind, and Texture.

int Teddy::Graphics::Texture::wrap_s [protected]
 

Texture s-axis wrap mode.

Definition at line 104 of file Texture.h.

Referenced by setWrap, and Texture.

int Teddy::Graphics::Texture::wrap_t [protected]
 

Texture t-axis wrap mode.

Definition at line 105 of file Texture.h.

Referenced by setWrap, and Texture.


The documentation for this class was generated from the following files: