hsqml-0.3.5.1: Haskell binding for Qt Quick

Safe HaskellNone
LanguageHaskell2010

Graphics.QML.Canvas

Description

Facility for drawing OpenGL graphics into the QML scenegraph.

To use this facility, you must place a HaskellCanvas item into your QML scene. This item can be imported from the HsQML.Canvas 1.0 module using an import statement in your QML script. It has several properties which can be set from QML:

displayMode
Specifies how the canvas is rendered with respect to the rest of the scene. Possible values are:
HaskellCanvas.Above
The canvas shares a buffer with the scenegraph and is painted top of other items.
HaskellCanvas.Inline
The canvas has its own framebuffer object and the contents of this buffer are painted inline with other items (default).
HaskellCanvas.Below
The canvas shares a buffer with the scenegraph and is painted underneath other items.
canvasWidth
Width of the framebuffer object in pixels. Defaults to the item width.
canvasHeight
Height of the framebuffer object in pixels. Defaults to the item height.
delegate
A marshalled OpenGLDelegate value which specifies the Haskell functions used to render the canvas.
model
A value passed to delegate's paint function. The canvas is repainted whenever this value changes.
status
Either HaskellCanvas.Okay or an error code (read only).

The HsQML.Canvas 1.0 module also contains another type of item called OpenGLConextControl which can be used to configure the OpenGL context used by your windows. When placed inside a QML window, it has several properties which when read return the current state of that window's OpenGL context, and when written to cause the window's context to be reconfigured with a request for the supplied setting. Note that as reconfiguring the context may cause a visible window to dis- and re-appear, it's recommended to supply the desired settings at startup or otherwise before the corresponding window is made visible. Available properties are as below:

majorVersion
Major component of the OpenGL version.
minorVersion
Minor component of the OpenGL version.
contextType
The type of OpenGL context. One of: OpenGLContextControl.UnknownType, OpenGLContextControl.OpenGL, or OpenGLContextControl.OpenGLES.
contextProfile
The OpenGL context's profile. One of: OpenGLContextControl.NoProfile, OpenGLContextControl.CoreProfile, or OpenGLContextControl.CompatibilityProfile.
deprecatedFunctions
True if deprecated functions are available.
depthBufferSize
Depth buffer size in bits.
stencilBufferSize
Stencil buffer size in bits.
when
Any changes to the OpenGL context while this property is set to false will be deferred until it is true again. The default value is true.

Synopsis

Documentation

data OpenGLDelegate Source #

Delegate for painting OpenGL graphics.

Instances

newOpenGLDelegate :: (Marshal m, CanGetFrom m ~ Yes) => (OpenGLSetup -> IO i) -> (OpenGLPaint i m -> IO ()) -> (i -> IO ()) -> IO OpenGLDelegate Source #

Creates a new OpenGLDelegate from setup, paint, and cleanup functions.

data OpenGLType Source #

Represents the type of an OpenGL context.

Constructors

OpenGLDesktop

Desktop OpenGL context.

OpenGLES

OpenGL ES context.

data OpenGLSetup Source #

Encapsulates parameters for OpenGL setup.

openGLType :: OpenGLSetup -> OpenGLType Source #

Type of OpenGL context.

openGLMajor :: OpenGLSetup -> Int Source #

Major version number of OpenGL context.

openGLMinor :: OpenGLSetup -> Int Source #

Minor version number of OpenGL context.

data OpenGLPaint s m Source #

Encapsulates parameters for OpenGL paint.

type OpenGLPaint' s = OpenGLPaint s Ignored Source #

Specialised version of OpenGLPaint with no model.

setupData :: OpenGLPaint s m -> s Source #

Gets the setup state.

modelData :: OpenGLPaint s m -> m Source #

Gets the active model.

matrixPtr :: OpenGLPaint s m -> Ptr CFloat Source #

Pointer to a 4 by 4 matrix which transform coordinates in the range (-1, -1) to (1, 1) on to the target rectangle in the scene.

itemWidth :: OpenGLPaint s m -> Float Source #

Width of the canvas item in its local coordinate system.

itemHeight :: OpenGLPaint s m -> Float Source #

Height of the canvas item in its local coordinate system.