]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/glcontext.cpp
47e1e59456cf50478cd3df8798b925407c643ec9
[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 { }
17
18
19 unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts):
20         runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d }",
21                 opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample))
22 { }
23
24
25
26 GLContext::GLContext(Window &wnd, const GLOptions &opts):
27         display(wnd.get_display()),
28         window(wnd)
29 {
30         platform_init(opts);
31
32         window.signal_resize.connect(sigc::mem_fun(this, &GLContext::window_resized));
33 }
34
35 #ifndef WITH_OPENGL
36 void GLContext::platform_init(const GLOptions &)
37 {
38         throw runtime_error("no OpenGL support");
39 }
40
41 GLContext::~GLContext()
42 { }
43
44 void GLContext::set_swap_interval(unsigned)
45 { }
46
47 void GLContext::swap_buffers()
48 { }
49
50 void GLContext::window_resized(unsigned, unsigned)
51 { }
52 #endif
53
54 } // namespace Graphics
55 } // namespace Msp