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