Gdk.GLContext¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
The GDK display used to create the GL context |
||
r/w/co |
The GL context this context shares data with |
||
r/w/co |
The GDK window bound to the GL context |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gdk.GLContext(**kwargs)¶
- Bases:
- Abstract:
Yes
Gdk.GLContextis an object representing the platform-specific OpenGL drawing context.Gdk.GLContextsare created for aGdk.WindowusingGdk.Window.create_gl_context(), and the context will match theGdk.Visualof the window.A
Gdk.GLContextis not tied to any particular normal framebuffer. For instance, it cannot draw to theGdk.Windowback buffer. The GDK repaint system is in full control of the painting to that. Instead, you can create render buffers or textures and useGdk.cairo_draw_from_gl() in the draw function of your widget to draw them. Then GDK will handle the integration of your rendering with that of other widgets.Support for
Gdk.GLContextis platform-specific, context creation can fail, returningNonecontext.A
Gdk.GLContexthas to be made “current” in order to start using it, otherwise any OpenGL call will be ignored.- Creating a new OpenGL context
In order to create a new
Gdk.GLContextinstance you need aGdk.Window, which you typically get during the realize call of a widget.A
Gdk.GLContextis not realized until eitherGdk.GLContext.make_current(), or until it is realized usingGdk.GLContext.realize(). It is possible to specify details of the GL context like the OpenGL version to be used, or whether the GL context should have extra state validation enabled after callingGdk.Window.create_gl_context() by callingGdk.GLContext.realize(). If the realization fails you have the option to change the settings of theGdk.GLContextand try again.- Using a
Gdk.GLContext
You will need to make the
Gdk.GLContextthe current context before issuing OpenGL calls; the system sends OpenGL commands to whichever context is current. It is possible to have multiple contexts, so you always need to ensure that the one which you want to draw with is the current one before issuing commands:gdk_gl_context_make_current (context);You can now perform your drawing using OpenGL commands.
You can check which
Gdk.GLContextis the current one by usingGdk.GLContext.get_current(); you can also unset anyGdk.GLContextthat is currently set by callingGdk.GLContext.clear_current().- classmethod clear_current()[source]¶
Clears the current
Gdk.GLContext.Any OpenGL call after this function returns will be ignored until
Gdk.GLContext.make_current() is called.New in version 3.16.
- classmethod get_current()[source]¶
- Returns:
the current
Gdk.GLContext, orNone- Return type:
Retrieves the current
Gdk.GLContext.New in version 3.16.
- get_debug_enabled()[source]¶
-
Retrieves the value set using
Gdk.GLContext.set_debug_enabled().New in version 3.16.
- get_display()[source]¶
- Returns:
a
Gdk.DisplayorNone- Return type:
Gdk.DisplayorNone
Retrieves the
Gdk.Displaythe self is created forNew in version 3.16.
- get_forward_compatible()[source]¶
-
Retrieves the value set using
Gdk.GLContext.set_forward_compatible().New in version 3.16.
- get_required_version()[source]¶
- Returns:
- major:
return location for the major version to request
- minor:
return location for the minor version to request
- Return type:
Retrieves the major and minor version requested by calling
Gdk.GLContext.set_required_version().New in version 3.16.
- Returns:
a
Gdk.GLContextorNone- Return type:
Retrieves the
Gdk.GLContextthat this self share data with.New in version 3.16.
- get_use_es()[source]¶
- Returns:
Trueif theGdk.GLContextis using an OpenGL ES profile- Return type:
Checks whether the self is using an OpenGL or OpenGL ES profile.
New in version 3.22.
- get_version()[source]¶
- Returns:
- major:
return location for the major version
- minor:
return location for the minor version
- Return type:
Retrieves the OpenGL version of the self.
The self must be realized prior to calling this function.
New in version 3.16.
- get_window()[source]¶
- Returns:
a
Gdk.WindoworNone- Return type:
Gdk.WindoworNone
Retrieves the
Gdk.Windowused by the self.New in version 3.16.
- is_legacy()[source]¶
-
Whether the
Gdk.GLContextis in legacy mode or not.The
Gdk.GLContextmust be realized before calling this function.When realizing a GL context, GDK will try to use the OpenGL 3.2 core profile; this profile removes all the OpenGL API that was deprecated prior to the 3.2 version of the specification. If the realization is successful, this function will return
False.If the underlying OpenGL implementation does not support core profiles, GDK will fall back to a pre-3.2 compatibility profile, and this function will return
True.You can use the value returned by this function to decide which kind of OpenGL API to use, or whether to do extension discovery, or what kind of shader programs to load.
New in version 3.20.
- realize()[source]¶
- Raises:
- Returns:
Trueif the context is realized- Return type:
Realizes the given
Gdk.GLContext.It is safe to call this function on a realized
Gdk.GLContext.New in version 3.16.
- set_debug_enabled(enabled)[source]¶
- Parameters:
enabled (
bool) – whether to enable debugging in the context
Sets whether the
Gdk.GLContextshould perform extra validations and run time checking. This is useful during development, but has additional overhead.The
Gdk.GLContextmust not be realized or made current prior to calling this function.New in version 3.16.
- set_forward_compatible(compatible)[source]¶
- Parameters:
compatible (
bool) – whether the context should be forward compatible
Sets whether the
Gdk.GLContextshould be forward compatible.Forward compatibile contexts must not support OpenGL functionality that has been marked as deprecated in the requested version; non-forward compatible contexts, on the other hand, must support both deprecated and non deprecated functionality.
The
Gdk.GLContextmust not be realized or made current prior to calling this function.New in version 3.16.
- set_required_version(major, minor)[source]¶
-
Sets the major and minor version of OpenGL to request.
Setting major and minor to zero will use the default values.
The
Gdk.GLContextmust not be realized or made current prior to calling this function.New in version 3.16.
- set_use_es(use_es)[source]¶
- Parameters:
use_es (
int) – whether the context should use OpenGL ES instead of OpenGL, or -1 to allow auto-detection
Requests that GDK create a OpenGL ES context instead of an OpenGL one, if the platform and windowing system allows it.
The self must not have been realized.
By default, GDK will attempt to automatically detect whether the underlying GL implementation is OpenGL or OpenGL ES once the self is realized.
You should check the return value of
Gdk.GLContext.get_use_es() after callingGdk.GLContext.realize() to decide whether to use the OpenGL or OpenGL ES API, extensions, or shaders.New in version 3.22.
Property Details¶
- Gdk.GLContext.props.display¶
- Name:
display- Type:
- Default Value:
- Flags:
The
Gdk.Displayused to create theGdk.GLContext.New in version 3.16.
- Name:
shared-context- Type:
- Default Value:
- Flags:
The
Gdk.GLContextthat this context is sharing data with, orNoneNew in version 3.16.
- Gdk.GLContext.props.window¶
- Name:
window- Type:
- Default Value:
- Flags:
The
Gdk.Windowthe gl context is bound to.New in version 3.16.