#include <sdl_texture.hpp>
Inherits Texture.
Public Member Functions | |
SDLTexture (SDL_Surface *sdlsurface) | |
virtual | ~SDLTexture () |
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] |
Private Member Functions | |
SDLTexture (const SDLTexture &) | |
SDLTexture & | operator= (const SDLTexture &) |
Classes | |
struct | ColorCache |
Definition at line 28 of file sdl_texture.hpp.
SDLTexture::SDLTexture | ( | SDL_Surface * | sdlsurface | ) |
Definition at line 627 of file sdl_texture.cpp.
References cache, NO_EFFECT, optimize(), scale(), texture, and Color::WHITE.
00627 : 00628 texture() 00629 { 00630 texture = optimize(image); 00631 //width = texture->w; 00632 //height = texture->h; 00633 int numerator = 1; 00634 int denominator = 1; 00635 //FIXME: float xfactor = (float) config->screenwidth / SCREEN_WIDTH; 00636 //FIXME: float yfactor = (float) config->screenheight / SCREEN_HEIGHT; 00637 /* FIXME: 00638 if(xfactor < yfactor) 00639 { 00640 numerator = config->screenwidth; 00641 denominator = SCREEN_WIDTH; 00642 } 00643 else 00644 { 00645 numerator = config->screenheight; 00646 denominator = SCREEN_HEIGHT; 00647 } 00648 */ 00649 cache[NO_EFFECT][Color::WHITE] = scale(texture, numerator, denominator); 00650 }
SDLTexture::~SDLTexture | ( | ) | [virtual] |
Definition at line 652 of file sdl_texture.cpp.
References texture.
00653 { 00654 SDL_FreeSurface(texture); 00655 }
SDLTexture::SDLTexture | ( | const SDLTexture & | ) | [private] |
SDL_Surface * SDLTexture::get_transform | ( | const Color & | color, | |
DrawingEffect | effect | |||
) |
Definition at line 658 of file sdl_texture.cpp.
References cache, colorize(), HORIZONTAL_FLIP, horz_flip(), NO_EFFECT, vert_flip(), VERTICAL_FLIP, and Color::WHITE.
00659 { 00660 if(cache[NO_EFFECT][color] == 0) { 00661 assert(cache[NO_EFFECT][Color::WHITE]); 00662 cache[NO_EFFECT][color] = colorize(cache[NO_EFFECT][Color::WHITE], color); 00663 } 00664 if(cache[effect][color] == 0) { 00665 assert(cache[NO_EFFECT][color]); 00666 switch(effect) { 00667 case NO_EFFECT: 00668 break; 00669 case HORIZONTAL_FLIP: 00670 cache[HORIZONTAL_FLIP][color] = horz_flip(cache[NO_EFFECT][color]); 00671 break; 00672 case VERTICAL_FLIP: 00673 cache[VERTICAL_FLIP][color] = vert_flip(cache[NO_EFFECT][color]); 00674 break; 00675 default: 00676 return 0; 00677 } 00678 } 00679 return cache[effect][color]; 00680 }
SDL_Surface* SDLTexture::get_texture | ( | ) | const [inline] |
Definition at line 95 of file sdl_texture.hpp.
References texture.
00096 { 00097 return texture; 00098 }
unsigned int SDLTexture::get_texture_width | ( | ) | const [inline, virtual] |
Implements Texture.
Definition at line 100 of file sdl_texture.hpp.
References texture.
00101 { 00102 return texture->w; 00103 }
unsigned int SDLTexture::get_texture_height | ( | ) | const [inline, virtual] |
Implements Texture.
Definition at line 105 of file sdl_texture.hpp.
References texture.
00106 { 00107 return texture->h; 00108 }
unsigned int SDLTexture::get_image_width | ( | ) | const [inline, virtual] |
Implements Texture.
Definition at line 110 of file sdl_texture.hpp.
References texture.
00111 { 00112 return texture->w; 00113 }
unsigned int SDLTexture::get_image_height | ( | ) | const [inline, virtual] |
Implements Texture.
Definition at line 115 of file sdl_texture.hpp.
References texture.
00116 { 00117 return texture->h; 00118 }
SDLTexture& SDLTexture::operator= | ( | const SDLTexture & | ) | [private] |
SDL_Surface* SDLTexture::texture [protected] |
Definition at line 31 of file sdl_texture.hpp.
Referenced by get_image_height(), get_image_width(), get_texture(), get_texture_height(), get_texture_width(), SDLTexture(), and ~SDLTexture().
ColorCache SDLTexture::cache[NUM_EFFECTS] [protected] |