Safe Haskell | None |
---|---|
Language | Haskell2010 |
Simplified 2D graphics system.
- module FWGL.Graphics.Generic
- type Object2D = Object Uniforms2D Geometry2D
- type IsObject2D globals inputs = (Subset Geometry2D inputs, Subset Uniforms2D globals, Set inputs, Set globals)
- type Group2D = Group (View2 : Uniforms2D) Geometry2D
- type IsGroup2D gs is = (Subset Geometry2D is, Subset (View2 : Uniforms2D) gs, Set is, Set gs)
- rect :: Backend => Texture -> Object2D
- image :: Backend => Texture -> Object2D
- sprite :: BackendIO => Texture -> Object2D
- depth :: (MemberGlobal Depth gs, GLES) => Float -> Object gs is -> Object gs is
- type Geometry2D = `[Position2, UV]`
- poly :: (IsObject2D Uniforms2D is, Backend) => Texture -> Geometry is -> Object Uniforms2D is
- mkGeometry2D :: GLES => [Vec2] -> [Vec2] -> [Word16] -> Geometry Geometry2D
- trans :: (MemberGlobal Transform2 gs, GLES) => Vec2 -> Object gs is -> Object gs is
- rot :: (MemberGlobal Transform2 gs, GLES) => Float -> Object gs is -> Object gs is
- scale :: (MemberGlobal Transform2 gs, GLES) => Float -> Object gs is -> Object gs is
- scaleV :: (MemberGlobal Transform2 gs, GLES) => Vec2 -> Object gs is -> Object gs is
- scaleTex :: (MemberGlobal Transform2 gs, Backend) => Texture -> Object gs is -> Object gs is
- scaleTexAR :: (MemberGlobal Transform2 gs, Backend) => Texture -> Object gs is -> Object gs is
- transform :: (MemberGlobal Transform2 gs, GLES) => Mat3 -> Object gs is -> Object gs is
- view :: (IsObject2D gs is, Backend) => Mat3 -> [Object gs is] -> Group (View2 : gs) is
- viewScreen :: (IsObject2D gs is, Backend) => Mat3 -> [Object gs is] -> Group (View2 : gs) is
- viewVP :: (IsObject2D gs is, Backend) => (Vec2 -> Mat3) -> [Object gs is] -> Group (View2 : gs) is
- layerS :: IsGroup2D gs is => Group gs is -> Layer
- transMat3 :: Vec2 -> Mat3
- rotMat3 :: Float -> Mat3
- scaleMat3 :: Vec2 -> Mat3
- screenMat3 :: Vec2 -> Mat3
- type Uniforms2D = `[Image, Depth, Transform2]`
- newtype Image = Image Sampler2D
- newtype Depth = Depth Float
- newtype Transform2 = Transform2 Mat3
- newtype View2 = View2 Mat3
Documentation
module FWGL.Graphics.Generic
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.
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
.
:: 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
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.
Transformation matrices
Uniforms
type Uniforms2D = `[Image, Depth, Transform2]` Source
An uniform that represents the texture used in the default 2D shader.
An uniform that represents the depth used in the default 2D shader.
newtype Transform2 Source
An uniform that represents the transformation matrix used in the default 2D shader.