GstGLContext * gst_gl_context_gpu_process_new (GstGLDisplay * display, GstGLAPI gl_api, GstGLProcAddrFunc proc_addr) { GstGLContext *context = NULL; GstGLContextGPUProcess *gpu_context = NULL; GstGLContextClass *context_class = NULL; GstGLWindow *window = NULL; GError *error = NULL; g_return_val_if_fail ((gst_gl_display_get_gl_api (display) & gl_api) != GST_GL_API_NONE, NULL); gpu_context = g_object_new (GST_GL_TYPE_CONTEXT_GPU_PROCESS, NULL); gpu_context->priv->gl_api = gl_api; context = GST_GL_CONTEXT (gpu_context); context->display = display; gst_gl_display_add_context (display, context); context_class = GST_GL_CONTEXT_GET_CLASS (context); context_class->get_current_context = NULL; context_class->get_proc_address = GST_DEBUG_FUNCPTR (proc_addr); gst_gl_context_activate (context, TRUE); gst_gl_context_fill_info (context, &error); if (error) { GST_ERROR_OBJECT (context, "Failed to create gpu process context: %s", error->message); g_error_free (error); gst_object_unref (context); return NULL; } window = GST_GL_WINDOW (gst_gl_window_gpu_process_new (display)); gst_gl_context_set_window (context, window); GST_GL_WINDOW_GET_CLASS (window)->open (window, NULL); gst_object_unref (window); return context; }
/** * gst_gl_context_new_wrapped: * @display: a #GstGLDisplay * @handle: the OpenGL context to wrap * @context_type: a #GstGLPlatform specifying the type of context in @handle * @available_apis: a #GstGLAPI containing the available OpenGL apis in @handle * * Wraps an existing OpenGL context into a #GstGLContext. * * Returns: a #GstGLContext wrapping @handle * * Since: 1.4 */ GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay * display, guintptr handle, GstGLPlatform context_type, GstGLAPI available_apis) { GstGLContext *context; GstGLWrappedContext *context_wrap = NULL; GstGLContextClass *context_class; GstGLAPI display_api; _init_debug (); display_api = gst_gl_display_get_gl_api (display); g_return_val_if_fail ((display_api & available_apis) != GST_GL_API_NONE, NULL); context_wrap = g_object_new (GST_GL_TYPE_WRAPPED_CONTEXT, NULL); if (!context_wrap) { /* subclass returned a NULL context */ GST_ERROR ("Could not wrap existing context"); return NULL; } context = (GstGLContext *) context_wrap; context->display = gst_object_ref (display); context->priv->sharegroup_id = _new_sharegroup_id (); context_wrap->handle = handle; context_wrap->platform = context_type; context_wrap->available_apis = available_apis; context_class = GST_GL_CONTEXT_GET_CLASS (context); #if GST_GL_HAVE_PLATFORM_GLX if (context_type == GST_GL_PLATFORM_GLX) { context_class->get_current_context = gst_gl_context_glx_get_current_context; context_class->get_proc_address = gst_gl_context_glx_get_proc_address; } #endif #if GST_GL_HAVE_PLATFORM_EGL if (context_type == GST_GL_PLATFORM_EGL) { context_class->get_current_context = gst_gl_context_egl_get_current_context; context_class->get_proc_address = gst_gl_context_egl_get_proc_address; } #endif #if GST_GL_HAVE_PLATFORM_CGL if (context_type == GST_GL_PLATFORM_CGL) { context_class->get_current_context = gst_gl_context_cocoa_get_current_context; context_class->get_proc_address = gst_gl_context_default_get_proc_address; } #endif #if GST_GL_HAVE_PLATFORM_WGL if (context_type == GST_GL_PLATFORM_WGL) { context_class->get_current_context = gst_gl_context_wgl_get_current_context; context_class->get_proc_address = gst_gl_context_wgl_get_proc_address; } #endif #if GST_GL_HAVE_PLATFORM_EAGL if (context_type == GST_GL_PLATFORM_EAGL) { context_class->get_current_context = gst_gl_context_eagl_get_current_context; context_class->get_proc_address = gst_gl_context_default_get_proc_address; } #endif if (!context_class->get_current_context) { /* we don't have API support */ gst_object_unref (context); return NULL; } return context; }