GLContext
open class GLContext : GLibObject.Object, GLContextProtocol
The GLContext type acts as a reference-counted owner of an underlying GdkGLContext instance.
It provides the methods that can operate on this data type through GLContextProtocol conformance.
Use GLContext as a strong reference or owner of a GdkGLContext instance.
GdkGLContext is an object representing the platform-specific
OpenGL drawing context.
GdkGLContexts are created for a GdkWindow using
gdk_window_create_gl_context(), 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_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, context creation
can fail, returning nil 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_gl_context_make_current(),
or until it is realized using 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 gdk_window_create_gl_context() by calling gdk_gl_context_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:
(C Language Example):
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_gl_context_get_current(); you can also unset any GdkGLContext
that is currently set by calling gdk_gl_context_clear_current().
-
Designated initialiser from the underlying `C` data type.This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
GLContextinstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GdkGLContext>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GdkGLContext>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GdkGLContext>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GdkGLContext>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGdkGLContext. i.e., ownership is transferred to theGLContextinstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GdkGLContext>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
GLContextProtocolWill retainGdkGLContext.Declaration
Swift
@inlinable public init<T>(gLContext other: T) where T : GLContextProtocolParameters
otheran instance of a related type that implements
GLContextProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
GLContextProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Retrieves the current
GdkGLContext.Declaration
Swift
@inlinable public static func getCurrent() -> GLContext!
View on GitHub
Install in Dash
GLContext Class Reference