]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/glcontext.h
8c8b49968b91090809b2e746cabe2716707468d4
[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         unsigned gl_version_major;
20         unsigned gl_version_minor;
21
22         GLOptions();
23 };
24
25
26 class unsupported_gl_mode: public std::runtime_error
27 {
28 public:
29         unsupported_gl_mode(const GLOptions &);
30         virtual ~unsupported_gl_mode() throw () { }
31 };
32
33
34 class GLContext
35 {
36 private:
37         struct Private;
38
39         Display &display;
40         Window &window;
41         Private *priv;
42
43 public:
44         GLContext(Window &wnd, const GLOptions &opts = GLOptions());
45 private:
46         void platform_init(const GLOptions &);
47 public:
48         ~GLContext();
49
50         void set_swap_interval(unsigned);
51
52         void swap_buffers();
53 private:
54         void window_resized(unsigned, unsigned);
55 };
56
57 } // namespace Graphics
58 } // namespace Msp
59
60 #endif