GstGL.GLContext

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GstGL.GLContext GstGL.GLContext Gst.Object->GstGL.GLContext

Subclasses:

None

Methods

Inherited:

Gst.Object (27), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

default_get_proc_address (gl_api, name)

class

get_current ()

class

get_current_gl_api (platform)

class

get_current_gl_context (context_type)

class

get_proc_address_with_platform (context_type, gl_api, name)

class

new (display)

class

new_wrapped (display, handle, context_type, available_apis)

activate (activate)

can_share (other_context)

check_feature (feature)

check_framebuffer_status (fbo_target)

check_gl_version (api, maj, min)

clear_framebuffer ()

clear_shader ()

create (other_context)

destroy ()

fill_info ()

get_config ()

get_display ()

get_gl_api ()

get_gl_context ()

get_gl_platform ()

get_gl_platform_version ()

get_gl_version ()

get_proc_address (name)

get_thread ()

get_window ()

is_shared ()

request_config (gl_config)

set_shared_with (share)

set_window (window)

supports_glsl_profile_version (version, profile)

supports_precision (version, profile)

supports_precision_highp (version, profile)

swap_buffers ()

thread_add (func, *data)

Virtual Methods

Inherited:

Gst.Object (1), GObject.Object (7)

do_activate (activate)

do_check_feature (feature)

do_choose_format ()

do_create_context (gl_api, other_context)

do_destroy_context ()

do_get_config ()

do_get_gl_api ()

do_get_gl_context ()

do_get_gl_platform ()

do_get_gl_platform_version ()

do_request_config (gl_config)

do_swap_buffers ()

Properties

Inherited:

Gst.Object (2)

Signals

Inherited:

Gst.Object (1), GObject.Object (1)

Fields

Inherited:

Gst.Object (1), GObject.Object (1)

Name

Type

Access

Description

display

GstGL.GLDisplay

r

gl_vtable

GstGL.GLFuncs

r

a list of OpenGL function pointers

parent

Gst.Object

r

window

GstGL.GLWindow

r

Class Details

class GstGL.GLContext(**kwargs)
Bases:

Gst.Object

Abstract:

Yes

Structure:

GstGL.GLContextClass

GstGL.GLContext 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.

Environment variables:

  • GST_GL_API: select which OpenGL API to create and OpenGL context for. Depending on the platform, the available values are ‘opengl’, ‘opengl3’ (core profile), and ‘gles2’. See the the GstGL.GLAPI enumeration for more details.

  • GST_GL_PLATFORM: select which OpenGL platform to create an OpenGL context with. Depending on the platform and the dependencies available build-time, the available values are, ‘glx’, ‘egl’, ‘cgl’, ‘wgl’, and ‘eagl’

  • GST_GL_CONFIG: select the configuration used for creating the OpenGL context and OpenGL surface. Written out as a Gst.Structure that has been serialized to string. e.g. GST_GL_CONFIG="gst-gl-context-config,red-size=8,green-size=8,blue-size=8,alpha-size=8,depth-size=16". Not all platforms will support the same level of functionality.

classmethod default_get_proc_address(gl_api, name)[source]
Parameters:
Returns:

an address pointing to name or None

Return type:

object or None

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

See also: GstGL.GLContext.get_proc_address()

New in version 1.4.

classmethod get_current()[source]
Returns:

the GstGL.GLContext active in the current thread or None

Return type:

GstGL.GLContext or None

See also GstGL.GLContext.activate().

New in version 1.6.

classmethod get_current_gl_api(platform)[source]
Parameters:

platform (GstGL.GLPlatform) – the GstGL.GLPlatform to retrieve the API for

Returns:

The version supported by the OpenGL context current in the calling thread or GstGL.GLAPI.NONE

major:

the major version

minor:

the minor version

Return type:

(GstGL.GLAPI, major: int, minor: int)

If an error occurs, major and minor are not modified and GstGL.GLAPI.NONE is returned.

New in version 1.6.

classmethod get_current_gl_context(context_type)[source]
Parameters:

context_type (GstGL.GLPlatform) – a GstGL.GLPlatform specifying the type of context to retrieve

Returns:

The OpenGL context handle current in the calling thread or None

Return type:

int or None

New in version 1.6.

classmethod get_proc_address_with_platform(context_type, gl_api, name)[source]
Parameters:
Returns:

a function pointer for name, or None

Return type:

object or None

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

See also GstGL.GLContext.get_proc_address().

New in version 1.6.

classmethod new(display)[source]
Parameters:

display (GstGL.GLDisplay) – a GstGL.GLDisplay

Returns:

a new GstGL.GLContext

Return type:

GstGL.GLContext

Create a new GstGL.GLContext with the specified display

New in version 1.4.

classmethod new_wrapped(display, handle, context_type, available_apis)[source]
Parameters:
Returns:

a GstGL.GLContext wrapping handle

Return type:

GstGL.GLContext or None

Wraps an existing OpenGL context into a GstGL.GLContext.

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

context_type must not be GstGL.GLPlatform.NONE or GstGL.GLPlatform.ANY

available_apis must not be GstGL.GLAPI.NONE or GstGL.GLAPI.ANY

New in version 1.4.

activate(activate)[source]
Parameters:

activate (bool) – True to activate, False to deactivate

Returns:

Whether the activation succeeded

Return type:

bool

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

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

New in version 1.4.

can_share(other_context)[source]
Parameters:

other_context (GstGL.GLContext) – another GstGL.GLContext

Returns:

whether self and other_context are able to share OpenGL resources.

Return type:

bool

Note: This will always fail for two wrapped GstGL.GLContext's

New in version 1.6.

check_feature(feature)[source]
Parameters:

feature (str) – a platform specific feature

Returns:

Whether feature is supported by self

Return type:

bool

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.

New in version 1.4.

check_framebuffer_status(fbo_target)[source]
Parameters:

fbo_target (int) – the GL value of the framebuffer target, GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER

Returns:

whether whether the current framebuffer is complete

Return type:

bool

Must be called with self current.

New in version 1.10.

check_gl_version(api, maj, min)[source]
Parameters:
  • api (GstGL.GLAPI) – api type required

  • maj (int) – major version required

  • min (int) – minor version required

Returns:

whether OpenGL context implements the required api and specified version.

Return type:

bool

New in version 1.4.

clear_framebuffer()[source]

Unbind the current framebuffer

New in version 1.10.

clear_shader()[source]

Clear’s the currently set shader from the GL state machine.

Note: must be called in the GL thread.

create(other_context)[source]
Parameters:

other_context (GstGL.GLContext or None) – a GstGL.GLContext to share OpenGL objects with

Raises:

GLib.Error

Returns:

whether the context could successfully be created

Return type:

bool

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.

Since 1.20, the configuration can be overriden with the environment variable GST_GL_CONFIG which is a stringified Gst.Structure as would be returned from GstGL.GLContext.get_config(). If GST_GL_CONFIG is not set, then the config will be chosen from other_context by calling GstGL.GLContext.get_config() on other_context. Otherwise, a default configuration is used.

Calling GstGL.GLContext.request_config()) before calling GstGL.GLContext.create() will override the config from other_context but will not override the GST_GL_CONFIG environment variable.

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

Should only be called once.

New in version 1.4.

destroy()[source]

Destroys an OpenGL context.

Should only be called after GstGL.GLContext.create() has been successfully called for this context.

New in version 1.6.

fill_info()[source]
Raises:

GLib.Error

Return type:

bool

Fills self'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 GstGL.GLContext's.

New in version 1.6.

get_config()[source]
Returns:

the configuration chosen for this OpenGL context.

Return type:

Gst.Structure or None

Retrieve the OpenGL configuration for this context. The context must have been successfully created for this function to return a valid value.

Not all implementations currently support retrieving the config and will return None when not supported.

New in version 1.20.

get_display()[source]
Returns:

the GstGL.GLDisplay associated with this self

Return type:

GstGL.GLDisplay

New in version 1.4.

get_gl_api()[source]
Returns:

the available OpenGL api

Return type:

GstGL.GLAPI

Get the currently enabled OpenGL api.

The currently available API may be limited by the GstGL.GLDisplay in use and/or the GstGL.GLWindow chosen.

New in version 1.4.

get_gl_context()[source]
Returns:

The platform specific backing OpenGL context

Return type:

int

Gets the backing OpenGL context used by self.

New in version 1.4.

get_gl_platform()[source]
Returns:

The platform specific backing OpenGL context

Return type:

GstGL.GLPlatform

Gets the OpenGL platform that used by self.

New in version 1.4.

get_gl_platform_version()[source]
Returns:

major:

return for the major version

minor:

return for the minor version

Return type:

(major: int, minor: int)

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

get_gl_version()[source]
Returns:

maj:

resulting major version

min:

resulting minor version

Return type:

(maj: int, min: int)

Returns the OpenGL version implemented by self. See GstGL.GLContext.get_gl_api() for retrieving the OpenGL api implemented by self.

New in version 1.4.

get_proc_address(name)[source]
Parameters:

name (str) – an opengl function name

Returns:

a function pointer or None

Return type:

object or None

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

Platform specific 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 self. The caller is responsible for ensuring that the returned function is a valid function to call in self 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.

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

New in version 1.4.

get_thread()[source]
Returns:

The GLib.Thread, self is current in or None

Return type:

GLib.Thread or None

New in version 1.6.

get_window()[source]
Returns:

the currently set window

Return type:

GstGL.GLWindow or None

New in version 1.4.

is_shared()[source]
Returns:

Whether the GstGL.GLContext has been shared with another GstGL.GLContext

Return type:

bool

New in version 1.8.

request_config(gl_config)[source]
Parameters:

gl_config (Gst.Structure or None) – a configuration structure for configuring the OpenGL context

Returns:

whether gl_config could be successfully set on self

Return type:

bool

Set the OpenGL configuration for this context. The context must not have been created for this function to succeed. Setting a None config has the affect of removing any specific configuration request.

Not all implementations currently support retrieving the config and this function will return False when not supported.

Note that calling this function may cause a subsequent GstGL.GLContext.create() to fail if config could not be matched with the platform-specific configuration.

Note that the actual config used may be differ from the requested values.

New in version 1.20.

set_shared_with(share)[source]
Parameters:

share (GstGL.GLContext) – another GstGL.GLContext

Will internally set self as shared with share

New in version 1.8.

set_window(window)[source]
Parameters:

window (GstGL.GLWindow) – a GstGL.GLWindow

Returns:

Whether the window was successfully updated

Return type:

bool

Set’s the current window on self to window. The window can only be changed before GstGL.GLContext.create() has been called and the window is not already running.

New in version 1.4.

supports_glsl_profile_version(version, profile)[source]
Parameters:
Returns:

Whether self supports the combination of version with profile

Return type:

bool

supports_precision(version, profile)[source]
Parameters:
Returns:

whether self supports the ‘precision’ specifier in GLSL shaders

Return type:

bool

New in version 1.16.

supports_precision_highp(version, profile)[source]
Parameters:
Returns:

whether self supports the ‘precision highp’ specifier in GLSL shaders

Return type:

bool

New in version 1.16.

swap_buffers()[source]

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

thread_add(func, *data)[source]
Parameters:

Execute func in the OpenGL thread of self with data

MT-safe

New in version 1.4.

do_activate(activate) virtual
Parameters:

activate (bool) – True to activate, False to deactivate

Returns:

Whether the activation succeeded

Return type:

bool

(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 GstGL.GLContext.set_window() for details.

New in version 1.4.

do_check_feature(feature) virtual
Parameters:

feature (str) – a platform specific feature

Returns:

Whether feature is supported by context

Return type:

bool

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.

New in version 1.4.

do_choose_format() virtual
Return type:

bool

do_create_context(gl_api, other_context) virtual
Parameters:
Return type:

bool

do_destroy_context() virtual
do_get_config() virtual
Returns:

the configuration chosen for this OpenGL context.

Return type:

Gst.Structure or None

Retrieve the OpenGL configuration for this context. The context must have been successfully created for this function to return a valid value.

Not all implementations currently support retrieving the config and will return None when not supported.

New in version 1.20.

do_get_gl_api() virtual
Returns:

the available OpenGL api

Return type:

GstGL.GLAPI

Get the currently enabled OpenGL api.

The currently available API may be limited by the GstGL.GLDisplay in use and/or the GstGL.GLWindow chosen.

New in version 1.4.

do_get_gl_context() virtual
Returns:

The platform specific backing OpenGL context

Return type:

int

Gets the backing OpenGL context used by context.

New in version 1.4.

do_get_gl_platform() virtual
Returns:

The platform specific backing OpenGL context

Return type:

GstGL.GLPlatform

Gets the OpenGL platform that used by context.

New in version 1.4.

do_get_gl_platform_version() virtual
Returns:

major:

return for the major version

minor:

return for the minor version

Return type:

(major: int, minor: int)

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

do_request_config(gl_config) virtual
Parameters:

gl_config (Gst.Structure or None) – a configuration structure for configuring the OpenGL context

Returns:

whether gl_config could be successfully set on context

Return type:

bool

Set the OpenGL configuration for this context. The context must not have been created for this function to succeed. Setting a None config has the affect of removing any specific configuration request.

Not all implementations currently support retrieving the config and this function will return False when not supported.

Note that calling this function may cause a subsequent GstGL.GLContext.create() to fail if config could not be matched with the platform-specific configuration.

Note that the actual config used may be differ from the requested values.

New in version 1.20.

do_swap_buffers() virtual

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