fwgl-0.1.4.0: Game engine

Safe HaskellNone
LanguageHaskell2010

FWGL.Graphics.D3

Contents

Description

Simplified 3D graphics system.

Synopsis

Documentation

3D Objects

type Object3D = Object Uniforms3D Geometry3D Source

A standard 3D object.

type IsObject3D globals inputs = (Subset Geometry3D inputs, Subset Uniforms3D globals, Set inputs, Set globals) Source

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

type Group3D = Group (View3 : Uniforms3D) Geometry3D Source

A standard 3D group.

type IsGroup3D gs is = (Subset Geometry3D is, Subset (View3 : Uniforms3D) gs, Set is, Set gs) Source

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

cube :: Backend => Texture -> Object3D Source

A cube with a specified Texture.

Geometry

type Geometry3D = `[Position3, UV, Normal3]` Source

A 3D geometry.

mesh :: (IsObject3D Uniforms3D is, Backend) => Texture -> Geometry is -> Object Uniforms3D is Source

A 3D object with a specified Geometry.

mkGeometry3D Source

Arguments

:: GLES 
=> [Vec3]

List of vertices.

-> [Vec2]

List of UV coordinates.

-> [Vec3]

List of normals.

-> [Word16]

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

-> Geometry Geometry3D 

Create a 3D Geometry. The first three lists should have the same length.

Transformations

trans :: (MemberGlobal Transform3 gs, GLES) => Vec3 -> Object gs is -> Object gs is Source

Translate a 3D Object.

rotX :: (MemberGlobal Transform3 gs, GLES) => Float -> Object gs is -> Object gs is Source

Rotate a 3D Object around the X axis.

rotY :: (MemberGlobal Transform3 gs, GLES) => Float -> Object gs is -> Object gs is Source

Rotate a 3D Object around the X axis.

rotZ :: (MemberGlobal Transform3 gs, GLES) => Float -> Object gs is -> Object gs is Source

Rotate a 3D Object around the X axis.

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

Rotate a 3D Object around a vector.

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

Scale a 3D Object.

scaleV :: (MemberGlobal Transform3 gs, GLES) => Vec3 -> Object gs is -> Object gs is Source

Scale a 3D Object in three dimensions.

transform :: (MemberGlobal Transform3 gs, GLES) => Mat4 -> Object gs is -> Object gs is Source

Transform a 3D Object.

Layers

view :: (IsObject3D gs is, Backend) => Mat4 -> [Object gs is] -> Group (View3 : gs) is Source

Create a group of objects with a view matrix.

viewPersp Source

Arguments

:: (IsObject3D gs is, Backend) 
=> Float

Near

-> Float

Far

-> Float

FOV

-> Mat4

View matrix

-> [Object gs is] 
-> Group (View3 : gs) is 

Create a group of objects with a view matrix and perspective projection.

viewOrtho Source

Arguments

:: (IsObject3D gs is, Backend) 
=> Float

Near

-> Float

Far

-> Float

Left

-> Float

Right

-> Float

Bottom

-> Float

Top

-> Mat4

View matrix

-> [Object gs is] 
-> Group (View3 : gs) is 

Create a group of objects with a view matrix and orthographic projection.

viewVP :: (IsObject3D gs is, Backend) => (Vec2 -> Mat4) -> [Object gs is] -> Group (View3 : gs) is Source

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

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

A Layer with the standard 3D program.

Matrices

View matrices

perspectiveMat4 Source

Arguments

:: Float

Near

-> Float

Far

-> Float

FOV

-> Float

Aspect ratio

-> Mat4 

4x4 perspective projection matrix.

perspectiveMat4Size Source

Arguments

:: Float

Near

-> Float

Far

-> Float

FOV

-> Vec2

Viewport size

-> Mat4 

4x4 perspective projection matrix, using width and height instead of the aspect ratio.

orthoMat4 Source

Arguments

:: Float

Near

-> Float

Far

-> Float

Left

-> Float

Right

-> Float

Bottom

-> Float

Top

-> Mat4 

4x4 orthographic projection matrix.

cameraMat4 Source

Arguments

:: Vec3

Eye

-> Float

Pitch

-> Float

Yaw

-> Mat4 

4x4 FPS camera matrix.

lookAtMat4 Source

Arguments

:: Vec3

Eye

-> Vec3

Target

-> Vec3

Up

-> Mat4 

4x4 "look at" camera matrix.

Transformation matrices

transMat4 :: Vec3 -> Mat4 Source

4x4 translation matrix.

rotXMat4 :: Float -> Mat4 Source

4x4 rotation matrix (X axis).

rotYMat4 :: Float -> Mat4 Source

4x4 rotation matrix (Y axis).

rotZMat4 :: Float -> Mat4 Source

4x4 rotation matrix (Z axis).

rotMat4 Source

Arguments

:: Vec3

Axis.

-> Float

Angle

-> Mat4 

4x4 rotation matrix.

scaleMat4 :: Vec3 -> Mat4 Source

4x4 scale matrix.

Uniforms