GstGL.GLContext¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
display |
r |
||
gl_vtable |
r |
a list of OpenGL function pointers |
|
parent |
r |
||
window |
r |
Class Details¶
- class GstGL.GLContext(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
GstGL.GLContextwraps 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 theGstGL.GLAPIenumeration 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 aGst.Structurethat 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:
gl_api (
GstGL.GLAPI) – aGstGL.GLAPIname (
str) – then function to get the address of
- Returns:
an address pointing to name or
None- Return type:
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.GLContextactive in the current thread orNone- Return type:
See also
GstGL.GLContext.activate().New in version 1.6.
- classmethod get_current_gl_api(platform)[source]¶
- Parameters:
platform (
GstGL.GLPlatform) – theGstGL.GLPlatformto 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.NONEis returned.New in version 1.6.
- classmethod get_current_gl_context(context_type)[source]¶
- Parameters:
context_type (
GstGL.GLPlatform) – aGstGL.GLPlatformspecifying the type of context to retrieve- Returns:
The OpenGL context handle current in the calling thread or
None- Return type:
New in version 1.6.
- classmethod get_proc_address_with_platform(context_type, gl_api, name)[source]¶
- Parameters:
context_type (
GstGL.GLPlatform) – aGstGL.GLPlatformgl_api (
GstGL.GLAPI) – aGstGL.GLAPIname (
str) – the name of the function to retrieve
- Returns:
a function pointer for name, or
None- Return type:
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) – aGstGL.GLDisplay- Returns:
a new
GstGL.GLContext- Return type:
Create a new
GstGL.GLContextwith the specified displayNew in version 1.4.
- classmethod new_wrapped(display, handle, context_type, available_apis)[source]¶
- Parameters:
display (
GstGL.GLDisplay) – aGstGL.GLDisplayhandle (
int) – the OpenGL context to wrapcontext_type (
GstGL.GLPlatform) – aGstGL.GLPlatformspecifying the type of context in handleavailable_apis (
GstGL.GLAPI) – aGstGL.GLAPIcontaining the available OpenGL apis in handle
- Returns:
a
GstGL.GLContextwrapping handle- Return type:
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.GLContextis active.context_type must not be
GstGL.GLPlatform.NONEorGstGL.GLPlatform.ANYavailable_apis must not be
GstGL.GLAPI.NONEorGstGL.GLAPI.ANYNew in version 1.4.
- activate(activate)[source]¶
- Parameters:
- Returns:
Whether the activation succeeded
- Return type:
(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.
- Parameters:
other_context (
GstGL.GLContext) – anotherGstGL.GLContext- Returns:
whether self and other_context are able to share OpenGL resources.
- Return type:
Note: This will always fail for two wrapped
GstGL.GLContext'sNew in version 1.6.
- check_feature(feature)[source]¶
- Parameters:
feature (
str) – a platform specific feature- Returns:
Whether feature is supported by self
- Return type:
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:
Must be called with self current.
New in version 1.10.
- check_gl_version(api, maj, min)[source]¶
- Parameters:
api (
GstGL.GLAPI) – api type requiredmaj (
int) – major version requiredmin (
int) – minor version required
- Returns:
whether OpenGL context implements the required api and specified version.
- Return type:
New in version 1.4.
- 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.GLContextorNone) – aGstGL.GLContextto share OpenGL objects with- Raises:
- Returns:
whether the context could successfully be created
- Return type:
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_CONFIGwhich is a stringifiedGst.Structureas would be returned fromGstGL.GLContext.get_config(). IfGST_GL_CONFIGis not set, then the config will be chosen from other_context by callingGstGL.GLContext.get_config() on other_context. Otherwise, a default configuration is used.Calling
GstGL.GLContext.request_config()) before callingGstGL.GLContext.create() will override the config from other_context but will not override theGST_GL_CONFIGenvironment variable.If an error occurs, and error is not
None, then error will contain details of the error andFalsewill 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:
- Return type:
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:
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
Nonewhen not supported.New in version 1.20.
- get_display()[source]¶
- Returns:
the
GstGL.GLDisplayassociated with this self- Return type:
New in version 1.4.
- get_gl_api()[source]¶
- Returns:
the available OpenGL api
- Return type:
Get the currently enabled OpenGL api.
The currently available API may be limited by the
GstGL.GLDisplayin use and/or theGstGL.GLWindowchosen.New in version 1.4.
- get_gl_context()[source]¶
- Returns:
The platform specific backing OpenGL context
- Return type:
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:
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:
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:
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]¶
-
Get a function pointer to a specified opengl function, name. If the the specific function does not exist,
Noneis 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
GSTGLAPIidentifier 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 orNone- Return type:
GLib.ThreadorNone
New in version 1.6.
- Returns:
Whether the
GstGL.GLContexthas been shared with anotherGstGL.GLContext- Return type:
New in version 1.8.
- request_config(gl_config)[source]¶
- Parameters:
gl_config (
Gst.StructureorNone) – a configuration structure for configuring the OpenGL context- Returns:
whether gl_config could be successfully set on self
- Return type:
Set the OpenGL configuration for this context. The context must not have been created for this function to succeed. Setting a
Noneconfig has the affect of removing any specific configuration request.Not all implementations currently support retrieving the config and this function will return
Falsewhen 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.
- Parameters:
share (
GstGL.GLContext) – anotherGstGL.GLContext
Will internally set self as shared with share
New in version 1.8.
- set_window(window)[source]¶
- Parameters:
window (
GstGL.GLWindow) – aGstGL.GLWindow- Returns:
Whether the window was successfully updated
- Return type:
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:
version (
GstGL.GLSLVersion) – aGstGL.GLSLVersionprofile (
GstGL.GLSLProfile) – aGstGL.GLSLProfile
- Returns:
Whether self supports the combination of version with profile
- Return type:
- supports_precision(version, profile)[source]¶
- Parameters:
version (
GstGL.GLSLVersion) – aGstGL.GLSLVersionprofile (
GstGL.GLSLProfile) – aGstGL.GLSLProfile
- Returns:
whether self supports the ‘precision’ specifier in GLSL shaders
- Return type:
New in version 1.16.
- supports_precision_highp(version, profile)[source]¶
- Parameters:
version (
GstGL.GLSLVersion) – aGstGL.GLSLVersionprofile (
GstGL.GLSLProfile) – aGstGL.GLSLProfile
- Returns:
whether self supports the ‘precision highp’ specifier in GLSL shaders
- Return type:
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:
- Returns:
Whether the activation succeeded
- Return type:
(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:
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_create_context(gl_api, other_context) virtual¶
- Parameters:
gl_api (
GstGL.GLAPI) –other_context (
GstGL.GLContext) –
- Return type:
create the OpenGL context
- do_destroy_context() virtual¶
destroy the OpenGL context
- do_get_config() virtual¶
- Returns:
the configuration chosen for this OpenGL context.
- Return type:
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
Nonewhen not supported.New in version 1.20.
- do_get_gl_api() virtual¶
- Returns:
the available OpenGL api
- Return type:
Get the currently enabled OpenGL api.
The currently available API may be limited by the
GstGL.GLDisplayin use and/or theGstGL.GLWindowchosen.New in version 1.4.
- do_get_gl_context() virtual¶
- Returns:
The platform specific backing OpenGL context
- Return type:
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:
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:
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.StructureorNone) – a configuration structure for configuring the OpenGL context- Returns:
whether gl_config could be successfully set on context
- Return type:
Set the OpenGL configuration for this context. The context must not have been created for this function to succeed. Setting a
Noneconfig has the affect of removing any specific configuration request.Not all implementations currently support retrieving the config and this function will return
Falsewhen 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.