Class

GdkGLContext

Description [src]

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

GdkGLContext is an object representing a platform-specific OpenGL draw context.

GdkGLContexts are created for a surface using gdk_surface_create_gl_context(), and the context will match the the characteristics of the surface.

A GdkGLContext is not tied to any particular normal framebuffer. For instance, it cannot draw to the surface 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 and 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 GdkSurface, which you typically get during the realize call of a widget.

A GdkGLContext is not realized until either gdk_gl_context_make_current() or gdk_gl_context_realize() is called. 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_surface_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 GdkDrawContext ancestor_0--this ancestor_1 GObject ancestor_1--ancestor_0

Functions

gdk_gl_context_clear_current

Clears the current GdkGLContext.

gdk_gl_context_get_current

Retrieves the current GdkGLContext.

Instance methods

gdk_gl_context_get_debug_enabled

Retrieves whether the context is doing extra validations and runtime checking.

gdk_gl_context_get_display

Retrieves the display the context is created for.

gdk_gl_context_get_forward_compatible

Retrieves whether the context is forward-compatible.

gdk_gl_context_get_required_version

Retrieves required OpenGL version.

gdk_gl_context_get_shared_context

Used to retrieves the GdkGLContext that this context share data with.

Deprecated since: 4.4

gdk_gl_context_get_surface

Retrieves the surface used by the context.

gdk_gl_context_get_use_es

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

gdk_gl_context_get_version

Retrieves the OpenGL version of the context.

gdk_gl_context_is_legacy

Whether the GdkGLContext is in legacy mode or not.

gdk_gl_context_is_shared

Checks if the two GL contexts can share resources.

Available since: 4.4

gdk_gl_context_make_current

Makes the context the current one.

gdk_gl_context_realize

Realizes the given GdkGLContext.

gdk_gl_context_set_debug_enabled

Sets whether the GdkGLContext should perform extra validations and runtime checking.

gdk_gl_context_set_forward_compatible

Sets whether the GdkGLContext should be forward-compatible.

gdk_gl_context_set_required_version

Sets the major and minor version of OpenGL to request.

gdk_gl_context_set_use_es

Requests that GDK create an OpenGL ES context instead of an OpenGL one.

Methods inherited from GdkDrawContext (6)
gdk_draw_context_begin_frame

Indicates that you are beginning the process of redrawing region on the contexts surface.

gdk_draw_context_end_frame

Ends a drawing operation started with gdk_draw_context_begin_frame().

gdk_draw_context_get_display

Retrieves the GdkDisplay the context is created for.

gdk_draw_context_get_frame_region

Retrieves the region that is currently being repainted.

gdk_draw_context_get_surface

Retrieves the surface that context is bound to.

gdk_draw_context_is_in_frame

Returns TRUE if context is in the process of drawing to its surface.

Methods inherited from GObject (42)

Properties

Gdk.GLContext:shared-context

Always NULL.

Deprecated since: 4.4

Properties inherited from GdkDrawContext (2)
Gdk.DrawContext:display

The GdkDisplay used to create the GdkDrawContext.

Gdk.DrawContext:surface

The GdkSurface the context is bound to.

Signals

Signals inherited from GObject (1)