Package: gdk

Class gdk-gl-context

Superclasses

g-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 is representing the platform-specific OpenGL drawing context.

The gdk-gl-context object is created for a gdk-window object using the function gdk-window-create-gl-context, and the context will match the gdk-visual object of the window.

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

A gdk-gl-context object is not realized until either the function gdk-gl-context-make-current, or until it is realized using the function 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 the function gdk-window-create-gl-context by calling the function gdk-gl-context-realize. 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 function gdk-gl-context-get-current. You can also unset any gdk-gl-context object that is currently set by calling the function gdk-gl-context-clear-current.
 

Slot Access Functions

Inherited Slot Access Functions

See also

2021-4-28