GlContext

abstract class GlContext(val gdkGlContextPointer: <Error class: unknown class><<Error class: unknown class>>) : DrawContext(source)

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

GdkGLContexts are created for a surface using method@Gdk.Surface.create_gl_context, and the context will match 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 func@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 method@Gdk.GLContext.make_current or method@Gdk.GLContext.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 method@Gdk.Surface.create_gl_context by calling method@Gdk.GLContext.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 func@Gdk.GLContext.get_current; you can also unset any GdkGLContext that is currently set by calling func@Gdk.GLContext.clear_current.

Skipped during bindings generation

  • parameter major: major: Out parameter is not supported

  • parameter major: major: Out parameter is not supported

Inheritors

Constructors

Link copied to clipboard
constructor(gdkGlContextPointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class GlContextImpl(pointer: <Error class: unknown class><<Error class: unknown class>>) : GlContext

The GlContextImpl type represents a native instance of the abstract GlContext class.

Properties

Link copied to clipboard
open var allowedApis: Glapi

The allowed APIs.

Link copied to clipboard
open val api: Glapi

The API currently in use.

Link copied to clipboard
open override val display: Display?

The GdkDisplay used to create the GdkDrawContext.

Link copied to clipboard
val gdkDrawContextPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gdkGlContextPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

This is deprecated since version 4.4.

Link copied to clipboard
open override val surface: Surface?

The GdkSurface the context is bound to.

Functions

Link copied to clipboard
open fun beginFrame(region: <Error class: unknown class>)

This is deprecated since version 4.16.

Link copied to clipboard
open fun endFrame()

This is deprecated since version 4.16.

Link copied to clipboard

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

Link copied to clipboard

Retrieves whether the context is forward-compatible.

Link copied to clipboard
open fun getFrameRegion(): <Error class: unknown class>?

This is deprecated since version 4.16.

Link copied to clipboard
open fun getUseEs(): Boolean

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

Link copied to clipboard
open fun isInFrame(): Boolean

This is deprecated since version 4.16.

Link copied to clipboard
open fun isLegacy(): Boolean

Whether the GdkGLContext is in legacy mode or not.

Link copied to clipboard
open fun isShared(other: GlContext): Boolean

Checks if the two GL contexts can share resources.

Link copied to clipboard
open fun makeCurrent()

Makes the @context the current one.

Link copied to clipboard
open fun realize(): <Error class: unknown class><Boolean>

Realizes the given GdkGLContext.

Link copied to clipboard
open fun setDebugEnabled(enabled: Boolean)

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

Link copied to clipboard
open fun setForwardCompatible(compatible: Boolean)

Sets whether the GdkGLContext should be forward-compatible.

Link copied to clipboard
open fun setRequiredVersion(major: <Error class: unknown class>, minor: <Error class: unknown class>)

Sets the major and minor version of OpenGL to request.

Link copied to clipboard
open fun setUseEs(useEs: <Error class: unknown class>)

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