New grow and skid sounds from remaxim
[supertux.git] / src / video / gl_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 #include <config.h>
20
21 #ifdef HAVE_OPENGL
22
23 #ifndef __GL_SURFACE_DATA_HPP__
24 #define __GL_SURFACE_DATA_HPP__
25
26 #include "surface.hpp"
27
28 namespace GL
29 {
30   class SurfaceData
31   {
32   private:
33     const Surface &surface;
34     float uv_left;
35     float uv_top;
36     float uv_right;
37     float uv_bottom;
38
39   public:
40     SurfaceData(const Surface &surface) :
41       surface(surface)
42     {
43       uv_left = (float) surface.get_x() / surface.get_texture()->get_texture_width();
44       uv_top = (float) surface.get_y() / surface.get_texture()->get_texture_height();
45       uv_right = (float) (surface.get_x() + surface.get_width()) / surface.get_texture()->get_texture_width();
46       uv_bottom = (float) (surface.get_y() + surface.get_height()) / surface.get_texture()->get_texture_height();
47     }
48
49     float get_uv_left() const
50     {
51       return surface.get_flipx() ? uv_right : uv_left;
52     }
53
54     float get_uv_top() const
55     {
56       return uv_top;
57     }
58
59     float get_uv_right() const
60     {
61       return surface.get_flipx() ? uv_left : uv_right;
62     }
63
64     float get_uv_bottom() const
65     {
66       return uv_bottom;
67     }
68   };
69 }
70
71 #endif
72
73 #endif