GLContext


Object Hierarchy:

Gdk.GLContext Gdk.GLContext Gdk.GLContext GLib.Object GLib.Object GLib.Object->Gdk.GLContext

Description:

[ CCode ( type_id = "gdk_gl_context_get_type ()" ) ]
public abstract class GLContext : Object

GLContext is an object representing the platform-specific OpenGL drawing context.

GLContexts are created for a Window using create_gl_context, and the context will match the Visual of the window.

A GLContext is not tied to any particular normal framebuffer. For instance, it cannot draw to the 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 use 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 GLContext is platform-specific, context creation can fail, returning null context.

A 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 GLContext instance you need a Window , which you typically get during the realize call of a widget.

A GLContext is not realized until either make_current, or until it is realized using 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 create_gl_context by calling realize. If the realization fails you have the option to change the settings of the GLContext and try again.

Using a GdkGLContext

You will need to make the 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 GLContext is the current one by using get_current; you can also unset any GLContext that is currently set by calling clear_current.


Namespace: Gdk
Package: gdk-3.0

Content:

Properties:

Static methods:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class GLib.Object



2022 vala-language.org