Class

GdkGLContext

Description [src]

abstract class Gdk.GLContext : GObject.Object {
  /* No available fields */
}

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.

Creating a new OpenGL context

In order to create a new GdkGLContext instance you need a GdkWindow, which you typically get during the realize call of a widget.

A GdkGLContext is not realized until either gdk_gl_context_make_current(), or until it is realized using gdk_gl_context_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 calling gdk_window_create_gl_context() by calling gdk_gl_context_realize(). If the realization fails you have the option to change the settings of the GdkGLContext and try again.

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:

  gdk_gl_context_make_current (context);

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().

Hierarchy

hierarchy this GdkGLContext ancestor_0 GObject ancestor_0--this

Ancestors

Functions

gdk_gl_context_clear_current

Clears the current GdkGLContext.

Available since: 3.16

gdk_gl_context_get_current

Retrieves the current GdkGLContext.

Available since: 3.16

Instance methods

gdk_gl_context_get_debug_enabled

Retrieves the value set using gdk_gl_context_set_debug_enabled().

Available since: 3.16

gdk_gl_context_get_display

Retrieves the GdkDisplay the context is created for.

Available since: 3.16

gdk_gl_context_get_forward_compatible

Retrieves the value set using gdk_gl_context_set_forward_compatible().

Available since: 3.16

gdk_gl_context_get_required_version

Retrieves the major and minor version requested by calling gdk_gl_context_set_required_version().

Available since: 3.16

gdk_gl_context_get_shared_context

Retrieves the GdkGLContext that this context share data with.

Available since: 3.16

gdk_gl_context_get_use_es

Checks whether the context is using an OpenGL or OpenGL ES profile.

Available since: 3.22

gdk_gl_context_get_version

Retrieves the OpenGL version of the context.

Available since: 3.16

gdk_gl_context_get_window

Retrieves the GdkWindow used by the context.

Available since: 3.16

gdk_gl_context_is_legacy

Whether the GdkGLContext is in legacy mode or not.

Available since: 3.20

gdk_gl_context_make_current

Makes the context the current one.

Available since: 3.16

gdk_gl_context_realize

Realizes the given GdkGLContext.

Available since: 3.16

gdk_gl_context_set_debug_enabled

Sets whether the GdkGLContext should perform extra validations and run time checking. This is useful during development, but has additional overhead.

Available since: 3.16

gdk_gl_context_set_forward_compatible

Sets whether the GdkGLContext should be forward compatible.

Available since: 3.16

gdk_gl_context_set_required_version

Sets the major and minor version of OpenGL to request.

Available since: 3.16

gdk_gl_context_set_use_es

Requests that GDK create a OpenGL ES context instead of an OpenGL one, if the platform and windowing system allows it.

Available since: 3.22

Methods inherited from GObject (42)

Properties

Gdk.GLContext:display

The GdkDisplay used to create the GdkGLContext.

Available since: 3.16

Gdk.GLContext:shared-context

The GdkGLContext that this context is sharing data with, or NULL.

Available since: 3.16

Gdk.GLContext:window

The GdkWindow the gl context is bound to.

Available since: 3.16

Signals

Signals inherited from GObject (1)