From: Ralf Jung Date: Wed, 3 Apr 2013 13:27:29 +0000 (+0200) Subject: Check whether swap interval value is supported X-Git-Url: https://git.ralfj.de/gltest.git/commitdiff_plain/92d3b1692f11658cad027cd597019eabd65faf89?ds=inline;hp=14716b59eedd024453c5d904a619d63a0f0fed85 Check whether swap interval value is supported --- diff --git a/eglbackend.cpp b/eglbackend.cpp index 0e4c937..04165c7 100644 --- a/eglbackend.cpp +++ b/eglbackend.cpp @@ -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"); } diff --git a/glwindow.cpp b/glwindow.cpp index 2d79639..ca6dbb9 100644 --- a/glwindow.cpp +++ b/glwindow.cpp @@ -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;