fwgl-0.1.4.0: Game engine

Safe HaskellNone
LanguageHaskell2010

FWGL.Graphics.D2

Contents

Description

Simplified 2D graphics system.

Synopsis

Documentation

2D Objects and Groups

type Object2D = Object Uniforms2D Geometry2D Source

A standard 2D object.

type IsObject2D globals inputs = (Subset Geometry2D inputs, Subset Uniforms2D globals, Set inputs, Set globals) Source

2D objects compatible with the standard 2D shader program.

type Group2D = Group (View2 : Uniforms2D) Geometry2D Source

A standard 2D object group.

type IsGroup2D gs is = (Subset Geometry2D is, Subset (View2 : Uniforms2D) gs, Set is, Set gs) Source

2D object groups compatible with the standard 2D shader program.

rect :: Backend => Texture -> Object2D Source

A rectangle with a specified Texture.

image :: Backend => Texture -> Object2D Source

A rectangle with the aspect ratio adapted to its texture.

sprite :: BackendIO => Texture -> Object2D Source

A rectangle with the size and aspect ratio adapted to the screen, assuming that you're using viewScreen or screenMat3.

depth :: (MemberGlobal Depth gs, GLES) => Float -> Object gs is -> Object gs is Source

Set the depth of a 2D Object.

Geometry

type Geometry2D = `[Position2, UV]` Source

A 2D geometry.

poly :: (IsObject2D Uniforms2D is, Backend) => Texture -> Geometry is -> Object Uniforms2D is Source

A 2D object with a specified Geometry.

mkGeometry2D Source

Arguments

:: GLES 
=> [Vec2]

List of vertices.

-> [Vec2]

List of UV coordinates.

-> [Word16]

Triangles expressed as triples of indices to the two lists above.

-> Geometry Geometry2D 

Create a 2D Geometry. The first two lists should have the same length.

Transformations

trans :: (MemberGlobal Transform2 gs, GLES) => Vec2 -> Object gs is -> Object gs is Source

Translate a 2D Object.

rot :: (MemberGlobal Transform2 gs, GLES) => Float -> Object gs is -> Object gs is Source

Rotate a 2D Object.

scale :: (MemberGlobal Transform2 gs, GLES) => Float -> Object gs is -> Object gs is Source

Scale a 2D Object.

scaleV :: (MemberGlobal Transform2 gs, GLES) => Vec2 -> Object gs is -> Object gs is Source

Scale a 2D Object in two dimensions.

scaleTex :: (MemberGlobal Transform2 gs, Backend) => Texture -> Object gs is -> Object gs is Source

Scale an Object so that it has the same size as the Texture, assuming viewScreen or screenMat3.

scaleTexAR :: (MemberGlobal Transform2 gs, Backend) => Texture -> Object gs is -> Object gs is Source

Scale an Object so that it has the same aspect ratio as the Texture

scaleV $ Vec2 1 (texture height / texture width).

transform :: (MemberGlobal Transform2 gs, GLES) => Mat3 -> Object gs is -> Object gs is Source

Transform a 2D Object.

Layers

view :: (IsObject2D gs is, Backend) => Mat3 -> [Object gs is] -> Group (View2 : gs) is Source

Create a group of objects with a view matrix.

viewScreen :: (IsObject2D gs is, Backend) => Mat3 -> [Object gs is] -> Group (View2 : gs) is Source

Create a group of objects with a view matrix and screenMat3.

viewVP :: (IsObject2D gs is, Backend) => (Vec2 -> Mat3) -> [Object gs is] -> Group (View2 : gs) is Source

Create a group of objects with a view matrix, depending on the size of the framebuffer.

layerS :: IsGroup2D gs is => Group gs is -> Layer Source

A Layer with the standard 2D program.

Transformation matrices

transMat3 :: Vec2 -> Mat3 Source

3x3 translation matrix.

rotMat3 :: Float -> Mat3 Source

3x3 rotation matrix.

scaleMat3 :: Vec2 -> Mat3 Source

3x3 scale matrix.

screenMat3 Source

Arguments

:: Vec2

Viewport size.

-> Mat3 

Convert the screen coordinates to GL coordinates.

Uniforms

newtype Image Source

An uniform that represents the texture used in the default 2D shader.

Constructors

Image Sampler2D 

newtype Depth Source

An uniform that represents the depth used in the default 2D shader.

Constructors

Depth Float 

newtype Transform2 Source

An uniform that represents the transformation matrix used in the default 2D shader.

Constructors

Transform2 Mat3 

newtype View2 Source

An uniform that represents the view matrix used in the default 2D shader.

Constructors

View2 Mat3