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