New grow and skid sounds from remaxim
[supertux.git] / src / video / gl_texture.hpp
1 //  $Id: gl_texture.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
20 #ifndef __GL_TEXTURE_HPP__
21 #define __GL_TEXTURE_HPP__
22
23 #ifdef HAVE_OPENGL
24
25 #include <config.h>
26 #include <SDL.h>
27
28 #include "texture.hpp"
29 #include "glutil.hpp"
30
31 /**
32  * This class is a wrapper around a texture handle. It stores the texture width
33  * and height and provides convenience functions for uploading SDL_Surfaces
34  * into the texture
35  */
36 namespace GL
37 {
38   class Texture : public ::Texture
39   {
40   protected:
41     GLuint handle;
42     unsigned int texture_width;
43     unsigned int texture_height;
44     unsigned int image_width;
45     unsigned int image_height;
46
47   public:
48     Texture(unsigned int width, unsigned int height);
49     Texture(SDL_Surface* image);
50     ~Texture();
51
52     const GLuint &get_handle() const {
53       return handle;
54     }
55
56     void set_handle(GLuint handle) {
57       this->handle = handle;
58     }
59
60     unsigned int get_texture_width() const
61     {
62       return texture_width;
63     }
64
65     unsigned int get_texture_height() const
66     {
67       return texture_height;
68     }
69
70     unsigned int get_image_width() const
71     {
72       return image_width;
73     }
74
75     unsigned int get_image_height() const
76     {
77       return image_height;
78     }
79
80     void set_image_width(unsigned int width)
81     {
82       image_width = width;
83     }
84
85     void set_image_height(unsigned int height)
86     {
87       image_height = height;
88     }
89
90   private:
91     void set_texture_params();
92   };
93 }
94
95 #endif
96
97 #endif
98