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