3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/core/error.h>
16 GLDisplayOptions::GLDisplayOptions():
23 GLWindow::GLWindow(unsigned w, unsigned h)
30 GLWindow::GLWindow(const DisplayOptions &dopt, const GLDisplayOptions &gl_dopt)
39 glXMakeCurrent(display, 0, 0);
40 glXDestroyContext(display, context);
43 void GLWindow::swap_buffers()
45 glXSwapBuffers(display, window);
53 attribs.push_back(GLX_RGBA);
54 attribs.push_back(GLX_BUFFER_SIZE);
55 attribs.push_back(24);
58 attribs.push_back(GLX_ALPHA_SIZE);
61 if(gl_options.doublebuffer)
62 attribs.push_back(GLX_DOUBLEBUFFER);
63 if(gl_options.multisample>0)
65 attribs.push_back(GLX_SAMPLE_BUFFERS_ARB);
66 attribs.push_back(gl_options.multisample);
70 XVisualInfo *visual=glXChooseVisual(display, DefaultScreen(display), &attribs.front());
72 throw Exception("Couldn't get a matching GLX visual");
74 context=glXCreateContext(display, visual, 0, true);
76 throw Exception("Couldn't create a GLX context");
80 glXMakeCurrent(display, window, context);
83 void GLWindow::on_resize()
85 glViewport(0, 0, options.width, options.height);