]> git.tdb.fi Git - libs/gui.git/blobdiff - source/gbase/glcontext.cpp
Exception changes
[libs/gui.git] / source / gbase / glcontext.cpp
index 22dca9010462d922ad800f19447609e5a1735024..b71383063c05d6edb036959e8034349897bff228 100644 (file)
@@ -9,7 +9,7 @@
 #endif
 #endif
 #include <msp/core/application.h>
-#include <msp/core/except.h>
+#include <msp/strings/format.h>
 #include "display.h"
 #include "glcontext.h"
 #include "window.h"
@@ -26,6 +26,12 @@ GLOptions::GLOptions():
 { }
 
 
+unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts):
+       runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d }",
+               opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample))
+{ }
+
+
 #ifdef WITH_OPENGL
 #ifdef WIN32
 typedef HGLRC Context;
@@ -71,7 +77,7 @@ GLContext::GLContext(Window &wnd, const GLOptions &opts):
 
        int pf_index = ChoosePixelFormat(dc, &pfd);
        if(!pf_index)
-               throw Exception("Couldn't find a suitable pixel format");
+               throw unsupported_gl_mode(opts);
        SetPixelFormat(dc, pf_index, &pfd);
 
        priv->context = wglCreateContext(dc);
@@ -112,7 +118,7 @@ GLContext::GLContext(Window &wnd, const GLOptions &opts):
 
        XVisualInfo *vi = glXChooseVisual(dpy, DefaultScreen(dpy), &attribs.front());
        if(!vi)
-               throw Exception("Couldn't find a suitable GLX visual");
+               throw unsupported_gl_mode(opts);
        priv->context = glXCreateContext(dpy, vi, 0, true);
 
        XSetWindowAttributes attr;
@@ -128,7 +134,7 @@ GLContext::GLContext(Window &wnd, const GLOptions &opts):
 #else
        (void)wnd;
        (void)opts;
-       throw Exception("OpenGL support not compiled in");
+       throw runtime_error("no OpenGL support");
 #endif
 
        window.signal_resize.connect(sigc::mem_fun(this, &GLContext::window_resized));