]> git.tdb.fi Git - libs/gui.git/blobdiff - source/glwindow.cpp
React to resize and close events
[libs/gui.git] / source / glwindow.cpp
index 530d33719f94567111fba56969fcfc3d3134d88e..3ae559050a406dcdfe6aeddb43925d9fa612a050 100644 (file)
@@ -11,8 +11,6 @@ Distributed under the LGPL
 
 using namespace std;
 
-#include <iostream>
-
 namespace Msp {
 
 GLDisplayOptions::GLDisplayOptions():
@@ -38,7 +36,7 @@ GLWindow::GLWindow(const DisplayOptions &dopt, const GLDisplayOptions &gl_dopt)
 
 GLWindow::~GLWindow()
 {
-       glXMakeCurrent(display, window, 0);
+       glXMakeCurrent(display, 0, 0);
        glXDestroyContext(display, context);
 }
 
@@ -77,13 +75,14 @@ void GLWindow::init()
        if(!context)
                throw Exception("Couldn't create a GLX context");
 
-       window=XCreateWindow(display, DefaultRootWindow(display), 0, 0, options.width, options.height, 0, CopyFromParent, InputOutput, CopyFromParent, 0, 0);
-       if(!window)
-               throw Exception("Couldn't create a window");
-
-       XSelectInput(display, window, ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask);
+       create();
 
        glXMakeCurrent(display, window, context);
 }
 
+void GLWindow::on_resize()
+{
+       glViewport(0, 0, options.width, options.height);
+}
+
 } // namespace Msp