gdk.glcontext
Module for [GLContext] class
Types 3
gdk.glcontext.GLContext is an object representing a platform-specific OpenGL draw context.
gdk.glcontext.GLContexts are created for a surface using gdk.surface.Surface.createGlContext, and the context will match the characteristics of the surface.
A gdk.glcontext.GLContext 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 gdk.glcontext.GLContext is platform-specific and context creation can fail, returning null context.
A gdk.glcontext.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 gdk.glcontext.GLContext instance you need a gdk.surface.Surface, which you typically get during the realize call of a widget.
A gdk.glcontext.GLContext is not realized until either gdk.glcontext.GLContext.makeCurrent or gdk.glcontext.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 gdk.surface.Surface.createGlContext by calling gdk.glcontext.GLContext.realize. If the realization fails you have the option to change the settings of the gdk.glcontext.GLContext and try again.
Using a GdkGLContext
You will need to make the gdk.glcontext.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 gdk.glcontext.GLContext is the current one by using gdk.glcontext.GLContext.getCurrent; you can also unset any gdk.glcontext.GLContext that is currently set by calling gdk.glcontext.GLContext.clearCurrent.
GLContextGidBuilder builder() static nothrowGet builder for [gdk.glcontext.GLContext] Returns: New builder objectgdk.types.GLAPI allowedApis() @property nothrowGet `allowedApis` property. Returns: The allowed APIs.void allowedApis(gdk.types.GLAPI propval) @property nothrowSet `allowedApis` property. Params: propval = The allowed APIs.gdk.glcontext.GLContext sharedContext() @property nothrowGet `sharedContext` property. Returns: Always nullgdk.glcontext.GLContext getCurrent() static nothrowRetrieves the current [gdk.glcontext.GLContext]. Returns: the current [gdk.glcontext.GLContext]gdk.types.GLAPI getAllowedApis() nothrowGets the allowed APIs set via [gdk.glcontext.GLContext.setAllowedApis]. Returns: the allowed APIsbool getDebugEnabled() nothrowRetrieves whether the context is doing extra validations and runtime checking.gdk.display.Display getDisplay() nothrowRetrieves the display the context is created for Returns: a [gdk.display.Display]void getRequiredVersion(out int major, out int minor) nothrowRetrieves required OpenGL version set as a requirement for the context realization. It will not change even if a greater OpenGL version is supported and used after the context is realized. See [gdk...gdk.glcontext.GLContext getSharedContext() nothrowUsed to retrieves the [gdk.glcontext.GLContext] that this context share data with.gdk.surface.Surface getSurface() nothrowRetrieves the surface used by the context. Returns: a [gdk.surface.Surface]bool getUseEs() nothrowChecks whether the context is using an OpenGL or OpenGL ES profile. Returns: true if the [gdk.glcontext.GLContext] is using an OpenGL ES profile; false if other profile is in use of if the context ...bool isShared(gdk.glcontext.GLContext other) nothrowChecks if the two GL contexts can share resources.bool realize()Realizes the given [gdk.glcontext.GLContext].void setAllowedApis(gdk.types.GLAPI apis) nothrowSets the allowed APIs. When [gdk.glcontext.GLContext.realize] is called, only the allowed APIs will be tried. If you set this to 0, realizing will always fail.void setDebugEnabled(bool enabled) nothrowSets whether the [gdk.glcontext.GLContext] should perform extra validations and runtime checking.void setForwardCompatible(bool compatible) nothrowSets whether the [gdk.glcontext.GLContext] should be forward-compatible.void setRequiredVersion(int major, int minor) nothrowSets the major and minor version of OpenGL to request.void setUseEs(int useEs) nothrowRequests that GDK create an OpenGL ES context instead of an OpenGL one.Fluent builder implementation template for gdk.glcontext.GLContext
T allowedApis(gdk.types.GLAPI propval) nothrowSet `allowedApis` property. Params: propval = The allowed APIs. Returns: Builder instance for fluent chainingT sharedContext(gdk.glcontext.GLContext propval) nothrowSet `sharedContext` property. Params: propval = Always nullFluent builder for gdk.glcontext.GLContext