]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/glcontext.h
ef6ef1b60f25989431e4d710c5916a84bdc64af1
[libs/gui.git] / source / graphics / glcontext.h
1 #ifndef MSP_GRAPHICS_GLCONTEXT_H_
2 #define MSP_GRAPHICS_GLCONTEXT_H_
3
4 #include <stdexcept>
5
6 namespace Msp {
7 namespace Graphics {
8
9 class Display;
10 class Window;
11
12 struct GLOptions
13 {
14         bool alpha;
15         bool stencil;
16         bool doublebuffer;
17         unsigned multisample;
18         bool forward_compatible;
19         bool core_profile;
20         unsigned gl_version_major;
21         unsigned gl_version_minor;
22
23         GLOptions();
24 };
25
26
27 class unsupported_gl_mode: public std::runtime_error
28 {
29 public:
30         unsupported_gl_mode(const GLOptions &);
31         virtual ~unsupported_gl_mode() throw () { }
32 };
33
34
35 class GLContext
36 {
37 private:
38         struct Private;
39
40         Display &display;
41         Window &window;
42         Private *priv;
43
44 public:
45         GLContext(Window &wnd, const GLOptions &opts = GLOptions());
46 private:
47         void platform_init(const GLOptions &);
48 public:
49         ~GLContext();
50
51         void set_swap_interval(unsigned);
52
53         void swap_buffers();
54 private:
55         void window_resized(unsigned, unsigned);
56 };
57
58 } // namespace Graphics
59 } // namespace Msp
60
61 #endif