Description
GdkGLContext is an object representing the platform-specific
OpenGL drawing context.
GdkGLContexts are created for a GdkWindow using
gdk_window_create_gl_context(), and the context will match
the GdkVisual of the window.
A GdkGLContext is not tied to any particular normal framebuffer.
For instance, it cannot draw to the GdkWindow back buffer. The GDK
repaint system is in full control of the painting to that. Instead,
you can create render buffers or textures and use gdk_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 GdkGLContext is platform-specific, context creation
can fail, returning NULL context.
A GdkGLContext has to be made "current" in order to start using
it, otherwise any OpenGL call will be ignored.
Using a GdkGLContext
You will need to make the GdkGLContext 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:
You can now perform your drawing using OpenGL commands.
You can check which GdkGLContext is the current one by using
gdk_gl_context_get_current(); you can also unset any GdkGLContext
that is currently set by calling gdk_gl_context_clear_current().
Functions
gdk_gl_context_get_version ()
void
gdk_gl_context_get_version (GdkGLContext *context,
int *major,
int *minor);
Retrieves the OpenGL version of the context
.
The context
must be realized prior to calling this function.
Since: 3.16
gdk_gl_context_set_required_version ()
void
gdk_gl_context_set_required_version (GdkGLContext *context,
int major,
int minor);
Sets the major and minor version of OpenGL to request.
Setting major
and minor
to zero will use the default values.
The GdkGLContext must not be realized or made current prior to calling
this function.
Since: 3.16
gdk_gl_context_set_debug_enabled ()
void
gdk_gl_context_set_debug_enabled (GdkGLContext *context,
gboolean enabled);
Sets whether the GdkGLContext should perform extra validations and
run time checking. This is useful during development, but has
additional overhead.
The GdkGLContext must not be realized or made current prior to
calling this function.
Since: 3.16
gdk_gl_context_set_forward_compatible ()
void
gdk_gl_context_set_forward_compatible (GdkGLContext *context,
gboolean compatible);
Sets whether the GdkGLContext 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 GdkGLContext must not be realized or made current prior to calling
this function.
Since: 3.16
gdk_gl_context_set_use_es ()
void
gdk_gl_context_set_use_es (GdkGLContext *context,
int use_es);
Requests that GDK create a OpenGL ES context instead of an OpenGL one,
if the platform and windowing system allows it.
The context
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 context
is realized.
You should check the return value of gdk_gl_context_get_use_es() after
calling gdk_gl_context_realize() to decide whether to use the OpenGL or
OpenGL ES API, extensions, or shaders.
Since: 3.22
gdk_gl_context_get_use_es ()
gboolean
gdk_gl_context_get_use_es (GdkGLContext *context);
Checks whether the context
is using an OpenGL or OpenGL ES profile.
Since: 3.22
gdk_gl_context_is_legacy ()
gboolean
gdk_gl_context_is_legacy (GdkGLContext *context);
Whether the GdkGLContext is in legacy mode or not.
The GdkGLContext 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.
Returns
TRUE if the GL context is in legacy mode
Since: 3.20
gdk_gl_context_make_current ()
void
gdk_gl_context_make_current (GdkGLContext *context);
Makes the context
the current one.
Since: 3.16
gdk_gl_context_clear_current ()
void
gdk_gl_context_clear_current (void);
Clears the current GdkGLContext.
Any OpenGL call after this function returns will be ignored
until gdk_gl_context_make_current() is called.
Since: 3.16