SDL::SurfaceData Class Reference

#include <sdl_surface_data.hpp>

List of all members.

Public Member Functions

 SurfaceData (const Surface &surface)
SDL_Rect * get_src_rect (DrawingEffect effect)

Private Attributes

const Surfacesurface
SDL_Rect src_rects [NUM_EFFECTS]


Detailed Description

Definition at line 31 of file sdl_surface_data.hpp.


Constructor & Destructor Documentation

SDL::SurfaceData::SurfaceData ( const Surface surface  )  [inline]

Definition at line 38 of file sdl_surface_data.hpp.

References Surface::get_height(), Surface::get_texture(), SDL::Texture::get_texture_height(), SDL::Texture::get_texture_width(), Surface::get_width(), Surface::get_x(), Surface::get_y(), HORIZONTAL_FLIP, NO_EFFECT, src_rects, surface, and VERTICAL_FLIP.

00038                                         :
00039       surface(surface)
00040     {
00041       int numerator   = 1;
00042       int denominator = 1;
00043       //float xfactor = 1.0f; // FIXME: (float) config->screenwidth  / SCREEN_WIDTH;
00044       //float yfactor = 1.0f; // FIXME: (float) config->screenheight / SCREEN_HEIGHT;
00045 
00046       /* FIXME: 
00047       if(xfactor < yfactor)
00048       {
00049         numerator = config->screenwidth;
00050         denominator = SCREEN_WIDTH;
00051       }
00052       else
00053       {
00054         numerator = config->screenheight;
00055         denominator = SCREEN_HEIGHT;
00056       }
00057       */
00058 
00059       src_rects[NO_EFFECT].x = surface.get_x() * numerator / denominator;
00060       src_rects[NO_EFFECT].y = surface.get_y() * numerator / denominator;
00061       src_rects[NO_EFFECT].w = surface.get_width() * numerator / denominator;
00062       src_rects[NO_EFFECT].h = surface.get_height() * numerator / denominator;
00063 
00064       int flipped_x = surface.get_texture()->get_texture_width() - surface.get_x() - surface.get_width();
00065       src_rects[HORIZONTAL_FLIP].x = flipped_x * numerator / denominator;
00066       src_rects[HORIZONTAL_FLIP].y = surface.get_y() * numerator / denominator;
00067       src_rects[HORIZONTAL_FLIP].w = surface.get_width() * numerator / denominator;
00068       src_rects[HORIZONTAL_FLIP].h = surface.get_height() * numerator / denominator;
00069 
00070       int flipped_y = surface.get_texture()->get_texture_height() - surface.get_y() - surface.get_height();
00071       src_rects[VERTICAL_FLIP].x = flipped_y * numerator / denominator;
00072       src_rects[VERTICAL_FLIP].y = surface.get_y() * numerator / denominator;
00073       src_rects[VERTICAL_FLIP].w = surface.get_width() * numerator / denominator;
00074       src_rects[VERTICAL_FLIP].h = surface.get_height() * numerator / denominator;
00075     }


Member Function Documentation

SDL_Rect* SDL::SurfaceData::get_src_rect ( DrawingEffect  effect  )  [inline]

Definition at line 77 of file sdl_surface_data.hpp.

References src_rects.

Referenced by SDL::Renderer::draw_surface(), and SDL::Lightmap::draw_surface().

00078     {
00079       return src_rects + effect;
00080     }


Member Data Documentation

const Surface& SDL::SurfaceData::surface [private]

Definition at line 34 of file sdl_surface_data.hpp.

Referenced by SurfaceData().

SDL_Rect SDL::SurfaceData::src_rects[NUM_EFFECTS] [private]

Definition at line 35 of file sdl_surface_data.hpp.

Referenced by get_src_rect(), and SurfaceData().


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