}
/**
+ * gl_swap_buffers:
+ * @dpy: an X11 #Display
+ * @win: an X11 #Window
+ *
+ * Promotes the contents of the back buffer of the @win window to
+ * become the contents of the front buffer. This simply is wrapper
+ * around glXSwapBuffers().
+ */
+void
+gl_swap_buffers(Display *dpy, Window win)
+{
+ glXSwapBuffers(dpy, win);
+}
+
+/**
* gl_bind_texture:
* @ts: a #GLTextureState
* @target: the target to which the texture is bound
guint is_constructed : 1;
guint foreign_context : 1;
guint foreign_window : 1;
+ guint swapped_buffers : 1;
};
enum {
if (priv->context) {
if (!priv->foreign_context) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- if (glXGetCurrentContext() == priv->context)
+ if (glXGetCurrentContext() == priv->context) {
+ /* XXX: if buffers were never swapped, the application
+ will crash later with the NVIDIA driver */
+ if (!priv->swapped_buffers)
+ gl_swap_buffers(dpy, GST_VAAPI_OBJECT_ID(window));
gl_make_current(dpy, None, NULL, NULL);
+ }
glXDestroyContext(dpy, priv->context);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
}
priv->is_constructed = FALSE;
priv->foreign_context = FALSE;
priv->foreign_window = FALSE;
+ priv->swapped_buffers = FALSE;
}
/**
g_return_if_fail(window->priv->is_constructed);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- glXSwapBuffers(
+ gl_swap_buffers(
GST_VAAPI_OBJECT_XDISPLAY(window),
GST_VAAPI_OBJECT_ID(window)
);
glClear(GL_COLOR_BUFFER_BIT);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
+
+ window->priv->swapped_buffers = TRUE;
}
/**