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

Contents

Description

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

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

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

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

A tGLContext 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 tGLContext and try again.

Using a GdkGLContext

You will need to make the tGLContext 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 tGLContext is the current one by using gLContextGetCurrent; you can also unset any tGLContext that is currently set by calling gLContextClearCurrent.

Synopsis

Exported types

newtype GLContext Source #

Memory-managed wrapper type.

Constructors

GLContext (ManagedPtr GLContext) 
Instances
Eq GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

Methods

(==) :: GLContext -> GLContext -> Bool

(/=) :: GLContext -> GLContext -> Bool

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

Methods

toGValue :: GLContext -> IO GValue

fromGValue :: GValue -> IO GLContext

HasParentTypes GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

type ParentTypes GLContext Source # 
Instance details

Defined in GI.Gdk.Objects.GLContext

type ParentTypes GLContext = Object ': ([] :: [Type])

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
(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 tGLContext.

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 tGLContext, or Nothing

Retrieves the current tGLContext.

Since: 3.16

getDebugEnabled

gLContextGetDebugEnabled Source #

Arguments

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

context: a tGLContext

-> 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 tGLContext

-> m (Maybe Display)

Returns: a tDisplay or Nothing

Retrieves the tDisplay the context is created for

Since: 3.16

getForwardCompatible

gLContextGetForwardCompatible Source #

Arguments

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

context: a tGLContext

-> 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 tGLContext

-> 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 tGLContext

-> m (Maybe GLContext)

Returns: a tGLContext or Nothing

Retrieves the tGLContext that this context share data with.

Since: 3.16

getUseEs

gLContextGetUseEs Source #

Arguments

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

context: a tGLContext

-> m Bool

Returns: True if the tGLContext 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 tGLContext

-> 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 tGLContext

-> m (Maybe Window)

Returns: a tWindow or Nothing

Retrieves the tWindow used by the context.

Since: 3.16

isLegacy

gLContextIsLegacy Source #

Arguments

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

context: a tGLContext

-> m Bool

Returns: True if the GL context is in legacy mode

Whether the tGLContext is in legacy mode or not.

The tGLContext 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 tGLContext

-> m () 

Makes the context the current one.

Since: 3.16

realize

gLContextRealize Source #

Arguments

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

context: a tGLContext

-> m ()

(Can throw GError)

Realizes the given tGLContext.

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

Since: 3.16

setDebugEnabled

gLContextSetDebugEnabled Source #

Arguments

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

context: a tGLContext

-> Bool

enabled: whether to enable debugging in the context

-> m () 

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

The tGLContext 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 tGLContext

-> Bool

compatible: whether the context should be forward compatible

-> m () 

Sets whether the tGLContext 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 tGLContext 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 tGLContext

-> 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 tGLContext 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 tGLContext:

-> 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 tDisplay used to create the tGLContext.

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 tGLContext 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 tWindow 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