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