SDL::Texture Class Reference

#include <sdl_texture.hpp>

Inherits Texture.

List of all members.

Public Member Functions

 Texture (SDL_Surface *sdlsurface)
virtual ~Texture ()
SDL_Surface * get_transform (const Color &color, DrawingEffect effect)
SDL_Surface * get_texture () const
unsigned int get_texture_width () const
unsigned int get_texture_height () const
unsigned int get_image_width () const
unsigned int get_image_height () const

Protected Attributes

SDL_Surface * texture
ColorCache cache [NUM_EFFECTS]

Classes

struct  ColorCache


Detailed Description

Definition at line 33 of file sdl_texture.hpp.


Constructor & Destructor Documentation

Texture::Texture ( SDL_Surface *  sdlsurface  ) 

Definition at line 609 of file sdl_texture.cpp.

References NO_EFFECT, optimize(), scale(), and Color::WHITE.

00610   {
00611     texture = optimize(image);
00612     //width = texture->w;
00613     //height = texture->h;
00614     int numerator   = 1;
00615     int denominator = 1;
00616     //FIXME: float xfactor = (float) config->screenwidth / SCREEN_WIDTH;
00617     //FIXME: float yfactor = (float) config->screenheight / SCREEN_HEIGHT;
00618     /* FIXME: 
00619     if(xfactor < yfactor)
00620     {
00621       numerator = config->screenwidth;
00622       denominator = SCREEN_WIDTH;
00623     }
00624     else
00625     {
00626       numerator = config->screenheight;
00627       denominator = SCREEN_HEIGHT;
00628     }
00629     */
00630     cache[NO_EFFECT][Color::WHITE] = scale(texture, numerator, denominator);
00631   }

Texture::~Texture (  )  [virtual]

Reimplemented from Texture.

Definition at line 633 of file sdl_texture.cpp.

00634   {
00635     SDL_FreeSurface(texture);
00636   }


Member Function Documentation

SDL_Surface * Texture::get_transform ( const Color color,
DrawingEffect  effect 
)

Definition at line 638 of file sdl_texture.cpp.

References colorize(), HORIZONTAL_FLIP, horz_flip(), NO_EFFECT, vert_flip(), VERTICAL_FLIP, and Color::WHITE.

00639   {
00640     if(cache[NO_EFFECT][color] == 0) {
00641       assert(cache[NO_EFFECT][Color::WHITE]);
00642       cache[NO_EFFECT][color] = colorize(cache[NO_EFFECT][Color::WHITE], color);
00643     }
00644     if(cache[effect][color] == 0) {
00645       assert(cache[NO_EFFECT][color]);
00646       switch(effect) {
00647         case NO_EFFECT:
00648           break;
00649         case HORIZONTAL_FLIP:
00650           cache[HORIZONTAL_FLIP][color] = horz_flip(cache[NO_EFFECT][color]);
00651           break;
00652         case VERTICAL_FLIP:
00653           cache[VERTICAL_FLIP][color] = vert_flip(cache[NO_EFFECT][color]);
00654           break;
00655         default:
00656           return 0;
00657       }
00658     }
00659     return cache[effect][color];
00660   }

SDL_Surface* SDL::Texture::get_texture (  )  const [inline]

Definition at line 94 of file sdl_texture.hpp.

References texture.

00095     {
00096       return texture;
00097     }

unsigned int SDL::Texture::get_texture_width (  )  const [inline, virtual]

Implements Texture.

Definition at line 99 of file sdl_texture.hpp.

References texture.

Referenced by SDL::SurfaceData::SurfaceData().

00100     {
00101       return texture->w;
00102     }

unsigned int SDL::Texture::get_texture_height (  )  const [inline, virtual]

Implements Texture.

Definition at line 104 of file sdl_texture.hpp.

References texture.

Referenced by SDL::SurfaceData::SurfaceData().

00105     {
00106       return texture->h;
00107     }

unsigned int SDL::Texture::get_image_width (  )  const [inline, virtual]

Implements Texture.

Definition at line 109 of file sdl_texture.hpp.

References texture.

00110     {
00111       return texture->w;
00112     }

unsigned int SDL::Texture::get_image_height (  )  const [inline, virtual]

Implements Texture.

Definition at line 114 of file sdl_texture.hpp.

References texture.

00115     {
00116       return texture->h;
00117     }


Member Data Documentation

SDL_Surface* SDL::Texture::texture [protected]

Definition at line 36 of file sdl_texture.hpp.

Referenced by get_image_height(), get_image_width(), get_texture(), get_texture_height(), and get_texture_width().

ColorCache SDL::Texture::cache[NUM_EFFECTS] [protected]

Definition at line 86 of file sdl_texture.hpp.


The documentation for this class was generated from the following files:
Generated on Mon Nov 16 03:38:18 2009 for SuperTux by  doxygen 1.5.1