SDLSurfaceData Class Reference

#include <sdl_surface_data.hpp>

Inherits SurfaceData.

List of all members.

Public Member Functions

 SDLSurfaceData (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 28 of file sdl_surface_data.hpp.


Constructor & Destructor Documentation

SDLSurfaceData::SDLSurfaceData ( const Surface surface  )  [inline]

Definition at line 35 of file sdl_surface_data.hpp.

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

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


Member Function Documentation

SDL_Rect* SDLSurfaceData::get_src_rect ( DrawingEffect  effect  )  [inline]

Definition at line 74 of file sdl_surface_data.hpp.

References src_rects.

Referenced by SDLRenderer::draw_surface(), and SDLLightmap::draw_surface().

00075   {
00076     return src_rects + effect;
00077   }


Member Data Documentation

const Surface& SDLSurfaceData::surface [private]

Definition at line 31 of file sdl_surface_data.hpp.

Referenced by SDLSurfaceData().

SDL_Rect SDLSurfaceData::src_rects[NUM_EFFECTS] [private]

Definition at line 32 of file sdl_surface_data.hpp.

Referenced by get_src_rect(), and SDLSurfaceData().


The documentation for this class was generated from the following file:
Generated on Mon Jun 9 03:38:35 2014 for SuperTux by  doxygen 1.5.1