- Reworked Surface class and drawing stuff:
[supertux.git] / src / video / image_texture.hpp
1 #ifndef __SURFACE_TEXTURE_HPP__
2 #define __SURFACE_TEXTURE_HPP__
3
4 #include <string>
5 #include "texture.hpp"
6
7 class ImageTexture : public Texture
8 {
9 private:
10   std::string filename;
11   float image_width;
12   float image_height;
13   int refcount;
14
15 public:
16   float get_image_width() const
17   {
18     return image_width;
19   }
20
21   float get_image_height() const
22   {
23     return image_height;
24   }
25   
26   float get_uv_right() const
27   {
28     return image_width / static_cast<float> (get_width());
29   }
30   
31   float get_uv_bottom() const
32   {
33     return image_height / static_cast<float> (get_height());
34   }
35
36   void ref()
37   {
38     refcount++;
39   }
40
41   void unref()
42   {
43     assert(refcount > 0);
44     refcount--;
45     if(refcount == 0)
46       release();
47   }
48
49 private:
50   friend class TextureManager;
51   
52   ImageTexture(SDL_Surface* surface);
53   virtual ~ImageTexture();
54
55   void release();
56 };
57
58 #endif
59