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.GLContext
is an object representing the platform-specific OpenGL drawing context.Gdk.GLContexts
are created for aGdk.Window
usingGdk.Window.create_gl_context
(), and the context will match theGdk.Visual
of the window.A
Gdk.GLContext
is not tied to any particular normal framebuffer. For instance, it cannot draw to theGdk.Window
back 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.GLContext
is platform-specific, context creation can fail, returningNone
context.A
Gdk.GLContext
has 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.GLContext
instance you need aGdk.Window
, which you typically get during the realize call of a widget.A
Gdk.GLContext
is 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.GLContext
and try again.- Using a
Gdk.GLContext
You will need to make the
Gdk.GLContext
the 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.GLContext
is the current one by usingGdk.GLContext.get_current
(); you can also unset anyGdk.GLContext
that 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.Display
orNone
- Return type:
Gdk.Display
orNone
Retrieves the
Gdk.Display
the 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.GLContext
orNone
- Return type:
Retrieves the
Gdk.GLContext
that this self share data with.New in version 3.16.
- get_use_es()[source]¶
- Returns:
True
if theGdk.GLContext
is 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.Window
orNone
- Return type:
Gdk.Window
orNone
Retrieves the
Gdk.Window
used by the self.New in version 3.16.
- is_legacy()[source]¶
-
Whether the
Gdk.GLContext
is in legacy mode or not.The
Gdk.GLContext
must 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:
True
if 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.GLContext
should perform extra validations and run time checking. This is useful during development, but has additional overhead.The
Gdk.GLContext
must 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.GLContext
should 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.GLContext
must 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.GLContext
must 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.Display
used to create theGdk.GLContext
.New in version 3.16.
- Name:
shared-context
- Type:
- Default Value:
- Flags:
The
Gdk.GLContext
that this context is sharing data with, orNone
New in version 3.16.
- Gdk.GLContext.props.window¶
- Name:
window
- Type:
- Default Value:
- Flags:
The
Gdk.Window
the gl context is bound to.New in version 3.16.