diff options
author | Wang Xin-yu (王昕宇) <comicfans44@gmail.com> | 2014-03-18 09:16:25 +0800 |
---|---|---|
committer | Matthew Waters <ystreet00@gmail.com> | 2014-03-20 15:45:02 +1100 |
commit | 05cb4bc6a58a03d8ff4fd95bec90f95ea3210d03 (patch) | |
tree | 3e7df257acba15a02ef8b54c829a9a06aab6d8a3 /gst-libs | |
parent | 58aa3e9d64c785adfba9c1dfd5a4fdd028b96eaf (diff) | |
download | gstreamer-plugins-bad-05cb4bc6a58a03d8ff4fd95bec90f95ea3210d03.tar.gz |
gl: use wglCreateContextAttribsARB to create share context
https://bugzilla.gnome.org/show_bug.cgi?id=726494
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/gl/win32/gstglcontext_wgl.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.c b/gst-libs/gst/gl/win32/gstglcontext_wgl.c index bc3ea2637..c2e7cdf5c 100644 --- a/gst-libs/gst/gl/win32/gstglcontext_wgl.c +++ b/gst-libs/gst/gl/win32/gstglcontext_wgl.c @@ -29,6 +29,7 @@ #include <gst/gl/gstglcontext.h> #include "gstglcontext_wgl.h" +#include <gl/wglext.h> #define gst_gl_context_wgl_parent_class parent_class G_DEFINE_TYPE (GstGLContextWGL, gst_gl_context_wgl, GST_GL_TYPE_CONTEXT); @@ -93,6 +94,7 @@ gst_gl_context_wgl_create_context (GstGLContext * context, GstGLWindow *window; GstGLContextWGL *context_wgl; HGLRC external_gl_context = NULL; + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; HDC device; context_wgl = GST_GL_CONTEXT_WGL (context); @@ -100,7 +102,7 @@ gst_gl_context_wgl_create_context (GstGLContext * context, device = (HDC) gst_gl_window_get_display (window); if (other_context) { - if (!GST_GL_IS_CONTEXT_WGL (other_context)) { + if (gst_gl_context_get_gl_platform (other_context) != GST_GL_PLATFORM_WGL) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_CONFIG, "Cannot share context with a non-WGL context"); @@ -121,18 +123,38 @@ gst_gl_context_wgl_create_context (GstGLContext * context, } g_assert (context_wgl->wgl_context); - GST_LOG ("gl context id: %" G_GUINTPTR_FORMAT, - (guintptr) context_wgl->wgl_context); if (external_gl_context) { - if (!wglShareLists (external_gl_context, context_wgl->wgl_context)) { + + wglMakeCurrent (device, context_wgl->wgl_context); + + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) + wglGetProcAddress ("wglCreateContextAttribsARB"); + + if (wglCreateContextAttribsARB != NULL) { + wglMakeCurrent (device, 0); + wglDeleteContext (context_wgl->wgl_context); + context_wgl->wgl_context = + wglCreateContextAttribsARB (device, external_gl_context, 0); + if (context_wgl->wgl_context == NULL) { + g_set_error (error, GST_GL_CONTEXT_ERROR, + GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, + "failed to share context through wglCreateContextAttribsARB 0x%x", + (unsigned int) GetLastError ()); + goto failure; + } + } else if (!wglShareLists (external_gl_context, context_wgl->wgl_context)){ g_set_error (error, GST_GL_CONTEXT_ERROR, - GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, "failed to share contexts 0x%x", - (unsigned int) GetLastError ()); + GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, + "failed to share contexts through wglShareLists 0x%x", + (unsigned int) GetLastError ()); goto failure; } } + GST_LOG ("gl context id: %" G_GUINTPTR_FORMAT, + (guintptr) context_wgl->wgl_context); + gst_object_unref (window); return TRUE; |