]> git.localhorst.tv Git - orbi.git/blob - src/graphics/Texture.h
initial collision tests
[orbi.git] / src / graphics / Texture.h
1 #ifndef ORBI_TEXTURE_H_
2 #define ORBI_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 orbi {
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         Texture(SDL_Renderer *, const char *file);
28
29         void Swap(Texture &);
30
31 public:
32         Vector<int> Size() const { return size; }
33
34         /// stretch this texture to completely fill given render target
35         void Fill(SDL_Renderer *);
36         /// stretch given clip to completely fill given render target
37         void Fill(SDL_Renderer *, Rect<int> clip);
38         /// copy entire texture as is to given coordinates
39         void Copy(SDL_Renderer *, Vector<int> to);
40         /// copy entire texture stretched to given rect
41         void Copy(SDL_Renderer *, Rect<int> to);
42         /// copy given clip to given coordinates
43         void Copy(SDL_Renderer *, Rect<int>, Vector<int> to);
44         /// copy given clip stretched to given rect
45         void Copy(SDL_Renderer *, Rect<int> clip, Rect<int> to);
46
47         /// set all color values
48         /// given array must hold at least Size().x * Size().y values
49         void SetColors(const Color *);
50
51 private:
52         SDL_Texture *tex;
53         Uint32 format;
54         Vector<int> size;
55
56 };
57
58 }
59
60
61 namespace std {
62
63 template<>
64 inline void swap<orbi::Texture>(orbi::Texture &lhs, orbi::Texture &rhs) {
65         lhs.Swap(rhs);
66 }
67
68 }
69
70 #endif