]> git.localhorst.tv Git - blank.git/blob - src/app/init.hpp
122210d1e96bc426a33de8b8a6fb938eda02976e
[blank.git] / src / app / init.hpp
1 #ifndef BLANK_APP_INIT_HPP_
2 #define BLANK_APP_INIT_HPP_
3
4 #include <SDL.h>
5 #include <stdexcept>
6 #include <string>
7
8
9 namespace blank {
10
11 class SDLError
12 : public std::runtime_error {
13
14 public:
15         SDLError();
16         explicit SDLError(const std::string &);
17
18 };
19
20
21 class InitSDL {
22
23 public:
24         InitSDL();
25         ~InitSDL();
26
27         InitSDL(const InitSDL &) = delete;
28         InitSDL &operator =(const InitSDL &) = delete;
29
30 };
31
32
33 class InitIMG {
34
35 public:
36         InitIMG();
37         ~InitIMG();
38
39         InitIMG(const InitIMG &) = delete;
40         InitIMG &operator =(const InitIMG &) = delete;
41
42 };
43
44
45 class InitTTF {
46
47 public:
48         InitTTF();
49         ~InitTTF();
50
51         InitTTF(const InitTTF &) = delete;
52         InitTTF &operator =(const InitTTF &) = delete;
53
54 };
55
56
57 class InitGL {
58
59 public:
60         explicit InitGL(bool double_buffer = true, int sample_size = 1);
61
62         InitGL(const InitGL &) = delete;
63         InitGL &operator =(const InitGL &) = delete;
64
65 };
66
67
68 class Window {
69
70 public:
71         Window();
72         ~Window();
73
74         Window(const Window &) = delete;
75         Window &operator =(const Window &) = delete;
76
77         void GrabInput();
78         void ReleaseInput();
79
80         void GrabMouse();
81         void ReleaseMouse();
82
83         SDL_Window *Handle() { return handle; }
84
85         void Flip();
86
87 private:
88         SDL_Window *handle;
89
90 };
91
92
93 class GLContext {
94
95 public:
96         explicit GLContext(SDL_Window *);
97         ~GLContext();
98
99         GLContext(const GLContext &) = delete;
100         GLContext &operator =(const GLContext &) = delete;
101
102 private:
103         SDL_GLContext ctx;
104
105 };
106
107
108 class InitGLEW {
109
110 public:
111         InitGLEW();
112
113         InitGLEW(const InitGLEW &) = delete;
114         InitGLEW &operator =(const InitGLEW &) = delete;
115
116 };
117
118
119 struct Init {
120
121         Init(bool double_buffer = true, int sample_size = 1);
122
123         InitSDL init_sdl;
124         InitIMG init_img;
125         InitTTF init_ttf;
126         InitGL init_gl;
127         Window window;
128         GLContext ctx;
129         InitGLEW init_glew;
130
131 };
132
133 }
134
135 #endif