Package: gdk

Class gdk:gl-context

Superclasses

gdk:draw-context, gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

allowed-apis
The allowed-apis property of type gdk:gl-api (Read / Write)
The allowed APIs. Since 4.6
Default value: '(:gl :gles)
api
The api property of type gdk:gl-api (Read)
The API currently in use. Since 4.6
Default value: :none
shared-context
The shared-context property of type gdk:gl-context (Read / Write / Construct only)
The GL context that this context is sharing data with, or nil. Deprecated since 4.4

Details

The gdk:gl-context object is an object representing the platform specific OpenGL draw context. A gdk:gl-context object is created for a gdk:surface object using the gdk:surface-create-gl-context function, and the context will match the the characteristics of the surface.

A gdk:gl-context object is not tied to any particular normal framebuffer. For instance, it cannot draw to the gdk: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 the gdk:cairo-draw-from-gl function 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 the gdk:gl-context object is platform specific, context creation can fail, returning a NULL context.

A gdk:gl-context object 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:gl-context object you need a gdk:surface object, which you typically get during the realize call of a widget.

A gdk:gl-context object is not realized until either the gdk:gl-context-make-current function, or until it is realized using the gdk:gl-context-realize function. 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 the gdk:surface-create-gl-context function by calling the gdk:gl-context-realize function. If the realization fails you have the option to change the settings of the gdk:gl-context object and try again.

Using a GdkGLContext
You will need to make the gdk:gl-ontext object 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:gl-context object is the current one by using the gdk:gl-context-current function. You can also unset any gdk:gl-context object that is currently set by calling the gdk:gl-context-clear-current function.
 

Slot Access Functions

Inherited Slot Access Functions

See also

#2023-8-3