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");
}
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;