gdk.glcontext

Module for [GLContext] class

Types 3

#GdkGLContext is an object representing the platform-specific OpenGL drawing context.

#GdkGLContexts are created for a #GdkWindow using gdk.window.Window.createGlContext, and the context will match the #GdkVisual of the window.

A #GdkGLContext is not tied to any particular normal framebuffer. For instance, it cannot draw to the #GdkWindow 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 gdk.global.cairoDrawFromGl 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, 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 #GdkWindow, which you typically get during the realize call of a widget.

A #GdkGLContext is not realized until either gdk.glcontext.GLContext.makeCurrent, or until it is realized using gdk.glcontext.GLContext.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 gdk.window.Window.createGlContext by calling gdk.glcontext.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 gdk.glcontext.GLContext.getCurrent; you can also unset any #GdkGLContext that is currently set by calling gdk.glcontext.GLContext.clearCurrent.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
GLContext self() nothrowReturns `this`, for use in `with` statements.
GLContextGidBuilder builder() static nothrowGet builder for [gdk.glcontext.GLContext] Returns: New builder object
gdk.display.Display display() @property nothrowGet `display` property. Returns: The #GdkDisplay used to create the #GdkGLContext.
gdk.glcontext.GLContext sharedContext() @property nothrowGet `sharedContext` property. Returns: The #GdkGLContext that this context is sharing data with, or null
gdk.window.Window window() @property nothrowGet `window` property. Returns: The #GdkWindow the gl context is bound to.
void clearCurrent() static nothrowClears the current #GdkGLContext.
gdk.glcontext.GLContext getCurrent() static nothrowRetrieves the current #GdkGLContext. Returns: the current #GdkGLContext, or null
bool getDebugEnabled() nothrowRetrieves the value set using [gdk.glcontext.GLContext.setDebugEnabled]. Returns: true if debugging is enabled
gdk.display.Display getDisplay() nothrowRetrieves the #GdkDisplay the context is created for Returns: a #GdkDisplay or null
bool getForwardCompatible() nothrowRetrieves the value set using [gdk.glcontext.GLContext.setForwardCompatible]. Returns: true if the context should be forward compatible
void getRequiredVersion(out int major, out int minor) nothrowRetrieves the major and minor version requested by calling [gdk.glcontext.GLContext.setRequiredVersion].
gdk.glcontext.GLContext getSharedContext() nothrowRetrieves the #GdkGLContext that this context share data with. Returns: a #GdkGLContext or null
bool getUseEs() nothrowChecks whether the context is using an OpenGL or OpenGL ES profile. Returns: true if the #GdkGLContext is using an OpenGL ES profile
void getVersion(out int major, out int minor) nothrowRetrieves the OpenGL version of the context.
gdk.window.Window getWindow() nothrowRetrieves the #GdkWindow used by the context. Returns: a #GdkWindow or null
bool isLegacy() nothrowWhether the #GdkGLContext is in legacy mode or not.
void makeCurrent() nothrowMakes the context the current one.
bool realize()Realizes the given #GdkGLContext.
void setDebugEnabled(bool enabled) nothrowSets whether the #GdkGLContext should perform extra validations and run time checking. This is useful during development, but has additional overhead.
void setForwardCompatible(bool compatible) nothrowSets whether the #GdkGLContext 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 a OpenGL ES context instead of an OpenGL one, if the platform and windowing system allows it.
Constructors
this(void * ptr, Flag!"Take" take)

Fluent builder implementation template for gdk.glcontext.GLContext

Methods
T display(gdk.display.Display propval) nothrowSet `display` property. Params: propval = The #GdkDisplay used to create the #GdkGLContext. Returns: Builder instance for fluent chaining
T sharedContext(gdk.glcontext.GLContext propval) nothrowSet `sharedContext` property. Params: propval = The #GdkGLContext that this context is sharing data with, or null Returns: Builder instance for fluent chaining
T window(gdk.window.Window propval) nothrowSet `window` property. Params: propval = The #GdkWindow the gl context is bound to. Returns: Builder instance for fluent chaining

Fluent builder for gdk.glcontext.GLContext

Methods
GLContext build() nothrowCreate object from builder. Returns: New object