]> git.localhorst.tv Git - blank.git/blob - src/app/init.hpp
cleanup
[blank.git] / src / app / init.hpp
1 #ifndef BLANK_APP_INIT_HPP_
2 #define BLANK_APP_INIT_HPP_
3
4 #include <al.h>
5 #include <SDL.h>
6 #include <stdexcept>
7 #include <string>
8
9
10 namespace blank {
11
12 class AlutError
13 : public std::runtime_error {
14
15 public:
16         explicit AlutError(ALenum);
17         AlutError(ALenum, const std::string &);
18
19 };
20
21 class SDLError
22 : public std::runtime_error {
23
24 public:
25         SDLError();
26         explicit SDLError(const std::string &);
27
28 };
29
30 class NetError
31 : public std::runtime_error {
32
33 public:
34         NetError();
35         explicit NetError(const std::string &);
36
37 };
38
39
40 class InitSDL {
41
42 public:
43         InitSDL();
44         ~InitSDL();
45
46         InitSDL(const InitSDL &) = delete;
47         InitSDL &operator =(const InitSDL &) = delete;
48
49 };
50
51
52 class InitVideo {
53
54 public:
55         InitVideo();
56         ~InitVideo();
57
58         InitVideo(const InitVideo &) = delete;
59         InitVideo &operator =(const InitVideo &) = delete;
60
61 };
62
63
64 class InitIMG {
65
66 public:
67         InitIMG();
68         ~InitIMG();
69
70         InitIMG(const InitIMG &) = delete;
71         InitIMG &operator =(const InitIMG &) = delete;
72
73 };
74
75
76 class InitNet {
77
78 public:
79         InitNet();
80         ~InitNet();
81
82         InitNet(const InitNet &) = delete;
83         InitNet &operator =(const InitNet &) = delete;
84
85 };
86
87
88 class InitTTF {
89
90 public:
91         InitTTF();
92         ~InitTTF();
93
94         InitTTF(const InitTTF &) = delete;
95         InitTTF &operator =(const InitTTF &) = delete;
96
97 };
98
99
100 class InitAL {
101
102 public:
103         InitAL();
104         ~InitAL() throw(AlutError);
105
106         InitAL(const InitAL &) = delete;
107         InitAL &operator =(const InitAL &) = delete;
108
109 };
110
111
112 class InitGL {
113
114 public:
115         explicit InitGL(bool double_buffer = true, int sample_size = 1);
116
117         InitGL(const InitGL &) = delete;
118         InitGL &operator =(const InitGL &) = delete;
119
120 };
121
122
123 class Window {
124
125 public:
126         Window();
127         ~Window();
128
129         Window(const Window &) = delete;
130         Window &operator =(const Window &) = delete;
131
132         void GrabInput();
133         void ReleaseInput();
134
135         void GrabMouse();
136         void ReleaseMouse();
137
138         SDL_Window *Handle() { return handle; }
139
140         void Flip();
141
142 private:
143         SDL_Window *handle;
144
145 };
146
147
148 class GLContext {
149
150 public:
151         explicit GLContext(SDL_Window *);
152         ~GLContext();
153
154         GLContext(const GLContext &) = delete;
155         GLContext &operator =(const GLContext &) = delete;
156
157 private:
158         SDL_GLContext ctx;
159
160 };
161
162
163 class InitGLEW {
164
165 public:
166         InitGLEW();
167
168         InitGLEW(const InitGLEW &) = delete;
169         InitGLEW &operator =(const InitGLEW &) = delete;
170
171 };
172
173
174 struct InitHeadless {
175
176         InitHeadless();
177
178         InitSDL init_sdl;
179         InitNet init_net;
180
181 };
182
183 struct Init {
184
185         Init(bool double_buffer = true, int sample_size = 1);
186
187         InitVideo init_video;
188         InitIMG init_img;
189         InitTTF init_ttf;
190         InitAL init_al;
191         InitGL init_gl;
192         Window window;
193         GLContext ctx;
194         InitGLEW init_glew;
195
196 };
197
198 }
199
200 #endif