Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
, orOpenGLContextControl.OpenGLES
. contextProfile
- The OpenGL context's profile. One of:
OpenGLContextControl.NoProfile
,OpenGLContextControl.CoreProfile
, orOpenGLContextControl.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.
- data OpenGLDelegate
- newOpenGLDelegate :: (Marshal m, CanGetFrom m ~ Yes) => (OpenGLSetup -> IO i) -> (OpenGLPaint i m -> IO ()) -> (i -> IO ()) -> IO OpenGLDelegate
- data OpenGLType
- data OpenGLSetup
- openGLType :: OpenGLSetup -> OpenGLType
- openGLMajor :: OpenGLSetup -> Int
- openGLMinor :: OpenGLSetup -> Int
- data OpenGLPaint s m
- type OpenGLPaint' s = OpenGLPaint s Ignored
- setupData :: OpenGLPaint s m -> s
- modelData :: OpenGLPaint s m -> m
- matrixPtr :: OpenGLPaint s m -> Ptr CFloat
- itemWidth :: OpenGLPaint s m -> Float
- itemHeight :: OpenGLPaint s m -> Float
Documentation
data OpenGLDelegate
Delegate for painting OpenGL graphics.
Instances
Marshal OpenGLDelegate | |
type MarshalMode OpenGLDelegate c d = ModeBidi c |
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.
Constructors
OpenGLDesktop | Desktop OpenGL context. |
OpenGLES | OpenGL ES context. |
Instances
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.