]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/glcontext.cpp
df6ad604ef7d2b9a4eb563abb7f1c4a458787e9f
[libs/gui.git] / source / graphics / glcontext.cpp
1 #include <stdexcept>
2 #include <msp/strings/format.h>
3 #include "glcontext.h"
4 #include "window.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace Graphics {
10
11 GLOptions::GLOptions():
12         alpha(false),
13         stencil(false),
14         doublebuffer(true),
15         multisample(0),
16         forward_compatible(false),
17         gl_version_major(0),
18         gl_version_minor(0)
19 { }
20
21
22 unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts):
23         runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d, .forward_compatible=%s, .gl_version=%d.%d }",
24                 opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample, opts.forward_compatible, opts.gl_version_major, opts.gl_version_minor))
25 { }
26
27
28
29 GLContext::GLContext(Window &wnd, const GLOptions &opts):
30         display(wnd.get_display()),
31         window(wnd)
32 {
33         platform_init(opts);
34
35         window.signal_resize.connect(sigc::mem_fun(this, &GLContext::window_resized));
36 }
37
38 #ifndef WITH_OPENGL
39 void GLContext::platform_init(const GLOptions &)
40 {
41         throw runtime_error("no OpenGL support");
42 }
43
44 GLContext::~GLContext()
45 { }
46
47 void GLContext::set_swap_interval(unsigned)
48 { }
49
50 void GLContext::swap_buffers()
51 { }
52
53 void GLContext::window_resized(unsigned, unsigned)
54 { }
55 #endif
56
57 } // namespace Graphics
58 } // namespace Msp