]> git.localhorst.tv Git - blank.git/blob - src/app/init.hpp
move RandomWalk into new "ai" module
[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
31 class InitSDL {
32
33 public:
34         InitSDL();
35         ~InitSDL();
36
37         InitSDL(const InitSDL &) = delete;
38         InitSDL &operator =(const InitSDL &) = delete;
39
40 };
41
42
43 class InitIMG {
44
45 public:
46         InitIMG();
47         ~InitIMG();
48
49         InitIMG(const InitIMG &) = delete;
50         InitIMG &operator =(const InitIMG &) = delete;
51
52 };
53
54
55 class InitTTF {
56
57 public:
58         InitTTF();
59         ~InitTTF();
60
61         InitTTF(const InitTTF &) = delete;
62         InitTTF &operator =(const InitTTF &) = delete;
63
64 };
65
66
67 class InitAL {
68
69 public:
70         InitAL();
71         ~InitAL();
72
73         InitAL(const InitAL &) = delete;
74         InitAL &operator =(const InitAL &) = delete;
75
76 };
77
78
79 class InitGL {
80
81 public:
82         explicit InitGL(bool double_buffer = true, int sample_size = 1);
83
84         InitGL(const InitGL &) = delete;
85         InitGL &operator =(const InitGL &) = delete;
86
87 };
88
89
90 class Window {
91
92 public:
93         Window();
94         ~Window();
95
96         Window(const Window &) = delete;
97         Window &operator =(const Window &) = delete;
98
99         void GrabInput();
100         void ReleaseInput();
101
102         void GrabMouse();
103         void ReleaseMouse();
104
105         SDL_Window *Handle() { return handle; }
106
107         void Flip();
108
109 private:
110         SDL_Window *handle;
111
112 };
113
114
115 class GLContext {
116
117 public:
118         explicit GLContext(SDL_Window *);
119         ~GLContext();
120
121         GLContext(const GLContext &) = delete;
122         GLContext &operator =(const GLContext &) = delete;
123
124 private:
125         SDL_GLContext ctx;
126
127 };
128
129
130 class InitGLEW {
131
132 public:
133         InitGLEW();
134
135         InitGLEW(const InitGLEW &) = delete;
136         InitGLEW &operator =(const InitGLEW &) = delete;
137
138 };
139
140
141 struct Init {
142
143         Init(bool double_buffer = true, int sample_size = 1);
144
145         InitSDL init_sdl;
146         InitIMG init_img;
147         InitTTF init_ttf;
148         InitAL init_al;
149         InitGL init_gl;
150         Window window;
151         GLContext ctx;
152         InitGLEW init_glew;
153
154 };
155
156 }
157
158 #endif