hsqml- Haskell binding for Qt Quick

Safe HaskellNone



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:

Specifies how the canvas is rendered with respect to the rest of the scene. Possible values are:
The canvas shares a buffer with the scenegraph and is painted top of other items.
The canvas has its own framebuffer object and the contents of this buffer are painted inline with other items (default).
The canvas shares a buffer with the scenegraph and is painted underneath other items.
Width of the framebuffer object in pixels. Defaults to the item width.
Height of the framebuffer object in pixels. Defaults to the item height.
A marshalled OpenGLDelegate value which specifies the Haskell functions used to render the canvas.
A value passed to delegate's paint function. The canvas is repainted whenever this value changes.
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:

Major component of the OpenGL version.
Minor component of the OpenGL version.
The type of OpenGL context. One of: OpenGLContextControl.UnknownType, OpenGLContextControl.OpenGL, or OpenGLContextControl.OpenGLES.
The OpenGL context's profile. One of: OpenGLContextControl.NoProfile, OpenGLContextControl.CoreProfile, or OpenGLContextControl.CompatibilityProfile.
True if deprecated functions are available.
Depth buffer size in bits.
Stencil buffer size in bits.
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.



data OpenGLDelegate

Delegate for painting OpenGL graphics.

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

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

data OpenGLType

Represents the type of an OpenGL context.



Desktop OpenGL context.


OpenGL ES context.

data OpenGLSetup

Encapsulates parameters for OpenGL setup.

openGLType :: OpenGLSetup -> OpenGLType

Type of OpenGL context.

openGLMajor :: OpenGLSetup -> Int

Major version number of OpenGL context.

openGLMinor :: OpenGLSetup -> Int

Minor version number of OpenGL context.

data OpenGLPaint s m

Encapsulates parameters for OpenGL paint.

type OpenGLPaint' s = OpenGLPaint s Ignored

Specialised version of OpenGLPaint with no model.

setupData :: OpenGLPaint s m -> s

Gets the setup state.

modelData :: OpenGLPaint s m -> m

Gets the active model.

matrixPtr :: OpenGLPaint s m -> Ptr CFloat

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

Width of the canvas item in its local coordinate system.

itemHeight :: OpenGLPaint s m -> Float

Height of the canvas item in its local coordinate system.