]> git.localhorst.tv Git - gworm.git/blob - src/graphics/Texture.h
added texture support
[gworm.git] / src / graphics / Texture.h
1 #ifndef GWORM_TEXTURE_H_
2 #define GWORM_TEXTURE_H_
3
4 #include "Color.h"
5 #include "Rect.h"
6 #include "Vector.h"
7
8 #include <algorithm>
9 #include <SDL.h>
10
11
12 namespace gworm {
13
14 class Texture {
15
16 public:
17         Texture();
18         ~Texture();
19
20         Texture(Texture &&);
21         Texture &operator =(Texture &&);
22
23         Texture(const Texture &) = delete;
24         Texture &operator =(const Texture &) = delete;
25
26         Texture(SDL_Renderer *, Uint32 format, int use, Vector<int> size);
27
28         void Swap(Texture &);
29
30 public:
31         Vector<int> Size() const { return size; }
32
33         /// stretch this texture to completely fill given render target
34         void Fill(SDL_Renderer *);
35         /// copy entire texture as is to given coordinates
36         void Copy(SDL_Renderer *, Vector<int> to);
37         /// copy entire texture stretched to given rect
38         void Copy(SDL_Renderer *, Rect<int> to);
39
40         /// set all color values
41         /// given array must hold at least Size().x * Size().y values
42         void SetColors(const Color *);
43
44 private:
45         SDL_Texture *tex;
46         Uint32 format;
47         Vector<int> size;
48
49 };
50
51 }
52
53
54 namespace std {
55
56 template<>
57 inline void swap<gworm::Texture>(gworm::Texture &lhs, gworm::Texture &rhs) {
58         lhs.Swap(rhs);
59 }
60
61 }
62
63 #endif