GstGLContext

GstGLContext — OpenGL context abstraction

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstGLContext

Includes

#include <gst/gl/gl.h>

Description

GstGLContext wraps an OpenGL context object in a uniform API. As a result of the limitation on OpenGL context, this object is not thread safe unless specified and must only be activated in a single thread.

Functions

GstGLContextThreadFunc ()

void
(*GstGLContextThreadFunc) (GstGLContext *context,
                           gpointer data);

Represents a function to run in the GL thread with context and data

Parameters

context

a GstGLContext

 

data

user data

 

gst_gl_context_new ()

GstGLContext *
gst_gl_context_new (GstGLDisplay *display);

Create a new GstGLContext with the specified display

Parameters

display

a GstGLDisplay

 

Returns

a new GstGLContext

Since: 1.4


gst_gl_context_new_wrapped ()

GstGLContext *
gst_gl_context_new_wrapped (GstGLDisplay *display,
                            guintptr handle,
                            GstGLPlatform context_type,
                            GstGLAPI available_apis);

Wraps an existing OpenGL context into a GstGLContext.

Note: The caller is responsible for ensuring that the OpenGL context represented by handle stays alive while the returned GstGLContext is active.

Parameters

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

 

Returns

a GstGLContext wrapping handle .

[transfer full]

Since: 1.4


gst_gl_context_create ()

gboolean
gst_gl_context_create (GstGLContext *context,
                       GstGLContext *other_context,
                       GError **error);

Creates an OpenGL context with the specified other_context as a context to share shareable OpenGL objects with. See the OpenGL specification for what is shared between OpenGL contexts.

If an error occurs, and error is not NULL, then error will contain details of the error and FALSE will be returned.

Should only be called once.

Parameters

context

a GstGLContext:

 

other_context

a GstGLContext to share OpenGL objects with.

[allow-none]

error

a GError.

[allow-none]

Returns

whether the context could successfully be created

Since: 1.4


gst_gl_context_destroy ()

void
gst_gl_context_destroy (GstGLContext *context);

Destroys an OpenGL context.

Should only be called after gst_gl_context_create() has been successfully called for this context.

Parameters

context

a GstGLContext:

 

Since: 1.6


gst_gl_context_activate ()

gboolean
gst_gl_context_activate (GstGLContext *context,
                         gboolean activate);

(De)activate the OpenGL context represented by this context .

In OpenGL terms, calls eglMakeCurrent or similar with this context and the currently set window. See gst_gl_context_set_window() for details.

Parameters

context

a GstGLContext

 

activate

TRUE to activate, FALSE to deactivate

 

Returns

Whether the activation succeeded

Since: 1.4


gst_gl_context_swap_buffers ()

void
gst_gl_context_swap_buffers (GstGLContext *context);

Swap the front and back buffers on the window attached to context . This will display the frame on the next refresh cycle.

Parameters

context

a GstGLContext

 

gst_gl_context_default_get_proc_address ()

gpointer
gst_gl_context_default_get_proc_address
                               (GstGLAPI gl_api,
                                const gchar *name);

A default implementation of the various GetProcAddress functions that looks for name in the OpenGL shared libraries or in the current process.

See also: gst_gl_context_get_proc_address()

Parameters

gl_api

a GstGLAPI

 

name

then function to get the address of

 

Returns

an address pointing to name or NULL

Since: 1.4


gst_gl_context_get_proc_address ()

gpointer
gst_gl_context_get_proc_address (GstGLContext *context,
                                 const gchar *name);

Get a function pointer to a specified opengl function, name . If the the specific function does not exist, NULL is returned instead.

Platform specfic functions (names starting 'egl', 'glX', 'wgl', etc) can also be retrieved using this method.

Note: This function may return valid function pointers that may not be valid to call in context . The caller is responsible for ensuring that the returned function is a valid function to call in context by either checking the OpenGL API and version or for an appropriate OpenGL extension.

Note: On success, you need to cast the returned function pointer to the correct type to be able to call it correctly. On 32-bit Windows, this will include the GSTGLAPI identifier to use the correct calling convention. e.g.

1
void (GSTGLAPI *PFN_glGetIntegerv) (GLenum name, GLint * ret)

Parameters

context

a GstGLContext

 

name

an opengl function name

 

Returns

a function pointer or NULL

Since: 1.4


gst_gl_context_get_proc_address_with_platform ()

gpointer
gst_gl_context_get_proc_address_with_platform
                               (GstGLPlatform context_type,
                                GstGLAPI gl_api,
                                const gchar *name);

Attempts to use the context_type specific GetProcAddress implementations to retreive name .

See also gst_gl_context_get_proc_address().

Parameters

context_type

a GstGLPlatform

 

gl_api

a GstGLAPI

 

name

the name of the function to retrieve

 

Returns

a function pointer for name , or NULL

Since: 1.6


gst_gl_context_get_window ()

GstGLWindow *
gst_gl_context_get_window (GstGLContext *context);

Parameters

context

a GstGLContext

 

Returns

the currently set window.

[transfer full][nullable]

Since: 1.4


gst_gl_context_set_window ()

gboolean
gst_gl_context_set_window (GstGLContext *context,
                           GstGLWindow *window);

Set's the current window on context to window . The window can only be changed before gst_gl_context_create() has been called and the window is not already running.

Parameters

context

a GstGLContext

 

window

a GstGLWindow.

[transfer full]

Returns

Whether the window was successfully updated

Since: 1.4


gst_gl_context_thread_add ()

void
gst_gl_context_thread_add (GstGLContext *context,
                           GstGLContextThreadFunc func,
                           gpointer data);

Execute func in the OpenGL thread of context with data

MT-safe

Parameters

context

a GstGLContext

 

func

a GstGLContextThreadFunc.

[scope call]

data

user data to call func with.

[closure]

Since: 1.4


gst_gl_context_get_display ()

GstGLDisplay *
gst_gl_context_get_display (GstGLContext *context);

Parameters

context

a GstGLContext:

 

Returns

the GstGLDisplay associated with this context .

[transfer full]

Since: 1.4


gst_gl_context_get_gl_api ()

GstGLAPI
gst_gl_context_get_gl_api (GstGLContext *context);

Get the currently enabled OpenGL api.

The currently available API may be limited by the GstGLDisplay in use and/or the GstGLWindow chosen.

Parameters

context

a GstGLContext

 

Returns

the available OpenGL api

Since: 1.4


gst_gl_context_get_gl_context ()

guintptr
gst_gl_context_get_gl_context (GstGLContext *context);

Gets the backing OpenGL context used by context .

Parameters

context

a GstGLContext:

 

Returns

The platform specific backing OpenGL context

Since: 1.4


gst_gl_context_get_gl_platform ()

GstGLPlatform
gst_gl_context_get_gl_platform (GstGLContext *context);

Gets the OpenGL platform that used by context .

Parameters

context

a GstGLContext:

 

Returns

The platform specific backing OpenGL context

Since: 1.4


gst_gl_context_get_gl_platform_version ()

void
gst_gl_context_get_gl_platform_version
                               (GstGLContext *context,
                                gint *major,
                                gint *minor);

Get the version of the OpenGL platform (GLX, EGL, etc) used. Only valid after a call to gst_gl_context_create_context().

Parameters

context

a GstGLContext

 

major

return for the major version.

[out]

minor

return for the minor version.

[out]

gst_gl_context_get_current_gl_context ()

guintptr
gst_gl_context_get_current_gl_context (GstGLPlatform context_type);

Parameters

context_type

a GstGLPlatform specifying the type of context to retrieve

 

Returns

The OpenGL context handle current in the calling thread or NULL

Since: 1.6


gst_gl_context_get_current_gl_api ()

GstGLAPI
gst_gl_context_get_current_gl_api (GstGLPlatform platform,
                                   guint *major,
                                   guint *minor);

If an error occurs, major and minor are not modified and GST_GL_API_NONE is returned.

Parameters

platform

the GstGLPlatform to retrieve the API for

 

major

the major version.

[out][allow-none]

minor

the minor version.

[out][allow-none]

Returns

The version supported by the OpenGL context current in the calling thread or GST_GL_API_NONE

Since: 1.6


gst_gl_context_get_thread ()

GThread *
gst_gl_context_get_thread (GstGLContext *context);

Parameters

context

a GstGLContext

 

Returns

The GThread, context is current in or NULL.

[transfer full]

Since: 1.6


gst_gl_context_can_share ()

gboolean
gst_gl_context_can_share (GstGLContext *context,
                          GstGLContext *other_context);

Note: This will always fail for two wrapped GstGLContext's

Parameters

context

a GstGLContext

 

other_context

another GstGLContext

 

Returns

whether context and other_context are able to share OpenGL resources.

Since: 1.6


gst_gl_context_is_shared ()

gboolean
gst_gl_context_is_shared (GstGLContext *context);

Parameters

context

a GstGLContext

 

Returns

Whether the GstGLContext has been shared with another GstGLContext

Since: 1.8


gst_gl_context_set_shared_with ()

void
gst_gl_context_set_shared_with (GstGLContext *context,
                                GstGLContext *share);

Will internally set context as shared with share

Parameters

context

a wrapped GstGLContext

 

share

another GstGLContext

 

Since: 1.8


gst_gl_context_check_feature ()

gboolean
gst_gl_context_check_feature (GstGLContext *context,
                              const gchar *feature);

Check for an OpenGL feature being supported.

Note: Most features require that the context be created before it is possible to determine their existence and so will fail if that is not the case.

Parameters

context

a GstGLContext

 

feature

a platform specific feature

 

Returns

Whether feature is supported by context

Since: 1.4


gst_gl_context_check_gl_version ()

gboolean
gst_gl_context_check_gl_version (GstGLContext *context,
                                 GstGLAPI api,
                                 gint maj,
                                 gint min);

Parameters

context

a GstGLContext

 

api

api type required

 

maj

major version required

 

min

minor version required

 

Returns

whether OpenGL context implements the required api and specified version.

Since: 1.4


gst_gl_context_get_gl_version ()

void
gst_gl_context_get_gl_version (GstGLContext *context,
                               gint *maj,
                               gint *min);

Returns the OpenGL version implemented by context . See gst_gl_context_get_gl_api() for retreiving the OpenGL api implemented by context .

Parameters

context

a GstGLContext

 

maj

resulting major version.

[out]

min

resulting minor version.

[out]

Since: 1.4


gst_gl_context_fill_info ()

gboolean
gst_gl_context_fill_info (GstGLContext *context,
                          GError **error);

Fills context 's info (version, extensions, vtable, etc) from the GL context in the current thread. Typically used with wrapped contexts to allow wrapped contexts to be used as regular GstGLContext's.

Parameters

context

a GstGLContext:

 

error

a GError to fill on failure.

[allow-none]

Since: 1.6


gst_gl_context_get_current ()

GstGLContext *
gst_gl_context_get_current (void);

See also gst_gl_context_activate().

Returns

the GstGLContext active in the current thread or NULL.

[transfer none]

Since: 1.6

Types and Values

GST_GL_CONTEXT_ERROR

#define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())

Error domain for GStreamer's GL context module. Errors in this domain will be from the GstGLContextError enumeration


enum GstGLContextError

OpenGL context errors.

Members

GST_GL_CONTEXT_ERROR_FAILED

Failed for an unspecified reason

 

GST_GL_CONTEXT_ERROR_WRONG_CONFIG

The configuration requested is not correct

 

GST_GL_CONTEXT_ERROR_WRONG_API

The OpenGL API requested is not correct

 

GST_GL_CONTEXT_ERROR_OLD_LIBS

The OpenGL libraries are too old

 

GST_GL_CONTEXT_ERROR_CREATE_CONTEXT

glXCreateContext (or similar) failed

 

GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE

A resource is not available

 

GstGLContext

typedef struct {
  GstGLFuncs *gl_vtable;
} GstGLContext;

Opaque GstGLContext object

Members

GstGLFuncs *gl_vtable;

a list of OpenGL function pointers

 

See Also

GstGLDisplay, GstGLWindow