mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
gl: use wglCreateContextAttribsARB to create share context
https://bugzilla.gnome.org/show_bug.cgi?id=726494
This commit is contained in:
parent
d3a823c459
commit
369bee2031
1 changed files with 28 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue