New grow and skid sounds from remaxim
[supertux.git] / src / video / sdl_surface_data.hpp
1 //  $Id: gl_surface_data.hpp 4063 2006-07-21 21:05:23Z anmaster $
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 #ifndef __SDL_SURFACE_DATA_HPP__
20 #define __SDL_SURFACE_DATA_HPP__
21
22 #include <config.h>
23
24 #include "surface.hpp"
25 #include "texture.hpp"
26 #include "main.hpp"
27 #include "gameconfig.hpp"
28
29 namespace SDL
30 {
31   class SurfaceData
32   {
33   private:
34     const Surface &surface;
35     SDL_Rect src_rects[NUM_EFFECTS];
36
37   public:
38     SurfaceData(const Surface &surface) :
39       surface(surface)
40     {
41       int numerator   = 1;
42       int denominator = 1;
43       //float xfactor = 1.0f; // FIXME: (float) config->screenwidth  / SCREEN_WIDTH;
44       //float yfactor = 1.0f; // FIXME: (float) config->screenheight / SCREEN_HEIGHT;
45
46       /* FIXME: 
47       if(xfactor < yfactor)
48       {
49         numerator = config->screenwidth;
50         denominator = SCREEN_WIDTH;
51       }
52       else
53       {
54         numerator = config->screenheight;
55         denominator = SCREEN_HEIGHT;
56       }
57       */
58
59       src_rects[NO_EFFECT].x = surface.get_x() * numerator / denominator;
60       src_rects[NO_EFFECT].y = surface.get_y() * numerator / denominator;
61       src_rects[NO_EFFECT].w = surface.get_width() * numerator / denominator;
62       src_rects[NO_EFFECT].h = surface.get_height() * numerator / denominator;
63
64       int flipped_x = surface.get_texture()->get_texture_width() - surface.get_x() - surface.get_width();
65       src_rects[HORIZONTAL_FLIP].x = flipped_x * numerator / denominator;
66       src_rects[HORIZONTAL_FLIP].y = surface.get_y() * numerator / denominator;
67       src_rects[HORIZONTAL_FLIP].w = surface.get_width() * numerator / denominator;
68       src_rects[HORIZONTAL_FLIP].h = surface.get_height() * numerator / denominator;
69
70       int flipped_y = surface.get_texture()->get_texture_height() - surface.get_y() - surface.get_height();
71       src_rects[VERTICAL_FLIP].x = flipped_y * numerator / denominator;
72       src_rects[VERTICAL_FLIP].y = surface.get_y() * numerator / denominator;
73       src_rects[VERTICAL_FLIP].w = surface.get_width() * numerator / denominator;
74       src_rects[VERTICAL_FLIP].h = surface.get_height() * numerator / denominator;
75     }
76
77     SDL_Rect *get_src_rect(DrawingEffect effect)
78     {
79       return src_rects + effect;
80     }
81   };
82 }
83
84 #endif