Package: gdk

Class gdk:gl-context

Superclasses

gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

display
The display property of type gdk:display (Read / Write / Construct)
The display used to create the OpenGL drawing context.
shared-context
The shared-context property of type gdk:gl-context (Read / Write / Construct)
The OpenGL drawing context that this context is sharing data with, or nil.
window
The window property of type gdk:window (Read / Write / Construct)
The window the OpenGL drawing context is bound to.

Details

The gdk:gl-context object is representing the platform-specific OpenGL drawing context. The gdk:gl-context object is created for a gdk:window object using the gdk:window-create-gl-context function, and the context will match the gdk:visual object of the window.

The gdk:gl-context object is not tied to any particular normal framebuffer. For instance, it cannot draw to the gdk: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 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.

The 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 instance you need a gdk:window object, which you typically get during the realize call of a widget.

The 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:window-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 OpenGl context
You will need to make the gdk:gl-context 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

2024-6-26