Check whether swap interval value is supported
authorRalf Jung <post@ralfj.de>
Wed, 3 Apr 2013 13:27:29 +0000 (15:27 +0200)
committerRalf Jung <post@ralfj.de>
Wed, 3 Apr 2013 13:27:29 +0000 (15:27 +0200)
eglbackend.cpp
glwindow.cpp

index 0e4c9378edc16d4f3004dfa463a68e4a75e7133d..04165c761460cedb93a6d99203a5b367a01381e4 100644 (file)
@@ -112,11 +112,26 @@ EGLBackend::~EGLBackend()
 void EGLBackend::swapBuffers() const
 {
        assert(context != EGL_NO_CONTEXT); // this implies the display is also initialized
-       eglSwapBuffers(display, surface);
+       if (eglSwapBuffers(display, surface) == EGL_FALSE)
+               exitEglError("Failed to swap buffers");
 }
 
 void EGLBackend::setSwapInterval(int i) const
 {
        assert(context != EGL_NO_CONTEXT);
-       eglSwapInterval(display, i);
+       // check if swap interval value is supported
+       EGLint val;
+       eglGetConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL, &val);
+       if (i < val) {
+               fprintf(stderr, "Cannot set swap interval to %d, minimum supported value is %d\n", i, val);
+               exit(1);
+       }
+       eglGetConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL, &val);
+       if (i > val) {
+               fprintf(stderr, "Cannot set swap interval to %d, maximum supported value is %d\n", i, val);
+               exit(1);
+       }
+       // use it
+       if (eglSwapInterval(display, i) == EGL_FALSE)
+               exitEglError("Failed to set swap interval");
 }
index 2d796391f145ee37166ee018826684024b4ec34f..ca6dbb95018d91fa416360a542fe32edc1c0ac33 100644 (file)
@@ -124,8 +124,6 @@ void GLWindow::exec()
                                        if (strcmp(XGetAtomName(display, event.xclient.message_type), "WM_PROTOCOLS") == 0 &&
                                                strcmp(XGetAtomName(display, event.xclient.data.l[0]), "WM_DELETE_WINDOW") == 0)
                                        {
-                                               XDestroyWindow(display, window);
-                                               window = 0;
                                                return;
                                        }
                                        break;