gi-gdk-3.0.22: Gdk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gdk.Objects.GLContext

Description

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

GdkGLContexts are created for a Window using windowCreateGlContext, and the context will match the Visual of the window.

A GLContext is not tied to any particular normal framebuffer. For instance, it cannot draw to the 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 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 GLContext is platform-specific, context creation can fail, returning Nothing context.

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

A GLContext is not realized until either gLContextMakeCurrent, or until it is realized using gLContextRealize. 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 windowCreateGlContext by calling gLContextRealize. If the realization fails you have the option to change the settings of the GLContext and try again.

Using a GdkGLContext

You will need to make the 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:

C code

 gdk_gl_context_make_current (context);

You can now perform your drawing using OpenGL commands.

You can check which GLContext is the current one by using gLContextGetCurrent; you can also unset any GLContext that is currently set by calling gLContextClearCurrent.

Synopsis

Exported types

newtype GLContext Source #

Memory-managed wrapper type.

Instances

Instances details
Eq GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

GObject GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

Methods

gobjectType :: IO GType #

IsGValue GLContext Source #

Convert GLContext to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gdk.Objects.GLContext

HasParentTypes GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

type ParentTypes GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

class (GObject o, IsDescendantOf GLContext o) => IsGLContext o Source #

Type class for types which can be safely cast to GLContext, for instance with toGLContext.

Instances

Instances details
(GObject o, IsDescendantOf GLContext o) => IsGLContext o Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

toGLContext :: (MonadIO m, IsGLContext o) => o -> m GLContext Source #

Cast to GLContext, for types for which this is known to be safe. For general casts, use castTo.

noGLContext :: Maybe GLContext Source #

A convenience alias for Nothing :: Maybe GLContext.

Methods

Overloaded methods

clearCurrent

gLContextClearCurrent :: (HasCallStack, MonadIO m) => m () Source #

Clears the current GLContext.

Any OpenGL call after this function returns will be ignored until gLContextMakeCurrent is called.

Since: 3.16

getCurrent

gLContextGetCurrent Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m (Maybe GLContext)

Returns: the current GLContext, or Nothing

Retrieves the current GLContext.

Since: 3.16

getDebugEnabled

gLContextGetDebugEnabled Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m Bool

Returns: True if debugging is enabled

Retrieves the value set using gLContextSetDebugEnabled.

Since: 3.16

getDisplay

gLContextGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m (Maybe Display)

Returns: a Display or Nothing

Retrieves the Display the context is created for

Since: 3.16

getForwardCompatible

gLContextGetForwardCompatible Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m Bool

Returns: True if the context should be forward compatible

Retrieves the value set using gLContextSetForwardCompatible.

Since: 3.16

getRequiredVersion

gLContextGetRequiredVersion Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m (Int32, Int32) 

Retrieves the major and minor version requested by calling gLContextSetRequiredVersion.

Since: 3.16

getSharedContext

gLContextGetSharedContext Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m (Maybe GLContext)

Returns: a GLContext or Nothing

Retrieves the GLContext that this context share data with.

Since: 3.16

getUseEs

gLContextGetUseEs Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m Bool

Returns: True if the GLContext is using an OpenGL ES profile

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

Since: 3.22

getVersion

gLContextGetVersion Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m (Int32, Int32) 

Retrieves the OpenGL version of the context.

The context must be realized prior to calling this function.

Since: 3.16

getWindow

gLContextGetWindow Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m (Maybe Window)

Returns: a Window or Nothing

Retrieves the Window used by the context.

Since: 3.16

isLegacy

gLContextIsLegacy Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m Bool

Returns: True if the GL context is in legacy mode

Whether the GLContext is in legacy mode or not.

The GLContext must be realized before calling this function.

When realizing a GL context, GDK will try to use the OpenGL 3.2 core profile; this profile removes all the OpenGL API that was deprecated prior to the 3.2 version of the specification. If the realization is successful, this function will return False.

If the underlying OpenGL implementation does not support core profiles, GDK will fall back to a pre-3.2 compatibility profile, and this function will return True.

You can use the value returned by this function to decide which kind of OpenGL API to use, or whether to do extension discovery, or what kind of shader programs to load.

Since: 3.20

makeCurrent

gLContextMakeCurrent Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m () 

Makes the context the current one.

Since: 3.16

realize

gLContextRealize Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> m ()

(Can throw GError)

Realizes the given GLContext.

It is safe to call this function on a realized GLContext.

Since: 3.16

setDebugEnabled

gLContextSetDebugEnabled Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> Bool

enabled: whether to enable debugging in the context

-> m () 

Sets whether the GLContext should perform extra validations and run time checking. This is useful during development, but has additional overhead.

The GLContext must not be realized or made current prior to calling this function.

Since: 3.16

setForwardCompatible

gLContextSetForwardCompatible Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> Bool

compatible: whether the context should be forward compatible

-> m () 

Sets whether the GLContext should be forward compatible.

Forward compatibile contexts must not support OpenGL functionality that has been marked as deprecated in the requested version; non-forward compatible contexts, on the other hand, must support both deprecated and non deprecated functionality.

The GLContext must not be realized or made current prior to calling this function.

Since: 3.16

setRequiredVersion

gLContextSetRequiredVersion Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext

-> Int32

major: the major version to request

-> Int32

minor: the minor version to request

-> m () 

Sets the major and minor version of OpenGL to request.

Setting major and minor to zero will use the default values.

The GLContext must not be realized or made current prior to calling this function.

Since: 3.16

setUseEs

gLContextSetUseEs Source #

Arguments

:: (HasCallStack, MonadIO m, IsGLContext a) 
=> a

context: a GLContext:

-> Int32

useEs: whether the context should use OpenGL ES instead of OpenGL, or -1 to allow auto-detection

-> m () 

Requests that GDK create a OpenGL ES context instead of an OpenGL one, if the platform and windowing system allows it.

The context must not have been realized.

By default, GDK will attempt to automatically detect whether the underlying GL implementation is OpenGL or OpenGL ES once the context is realized.

You should check the return value of gLContextGetUseEs after calling gLContextRealize to decide whether to use the OpenGL or OpenGL ES API, extensions, or shaders.

Since: 3.22

Properties

display

The Display used to create the GLContext.

Since: 3.16

constructGLContextDisplay :: (IsGLContext o, IsDisplay a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “display” property. This is rarely needed directly, but it is used by new.

getGLContextDisplay :: (MonadIO m, IsGLContext o) => o -> m (Maybe Display) Source #

Get the value of the “display” property. When overloading is enabled, this is equivalent to

get gLContext #display

sharedContext

The GLContext that this context is sharing data with, or Nothing

Since: 3.16

constructGLContextSharedContext :: (IsGLContext o, IsGLContext a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “shared-context” property. This is rarely needed directly, but it is used by new.

getGLContextSharedContext :: (MonadIO m, IsGLContext o) => o -> m (Maybe GLContext) Source #

Get the value of the “shared-context” property. When overloading is enabled, this is equivalent to

get gLContext #sharedContext

window

The Window the gl context is bound to.

Since: 3.16

constructGLContextWindow :: (IsGLContext o, IsWindow a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “window” property. This is rarely needed directly, but it is used by new.

getGLContextWindow :: (MonadIO m, IsGLContext o) => o -> m (Maybe Window) Source #

Get the value of the “window” property. When overloading is enabled, this is equivalent to

get gLContext #window