Safe Haskell | None |
---|---|
Language | Haskell2010 |
Simplified 3D graphics system.
- data Element
- cube :: GLES => Texture -> Element
- data Geometry is
- type Geometry3 = `[Position3, UV, Normal3]`
- geom :: Texture -> Geometry Geometry3 -> Element
- mkGeometry3 :: GLES => [V3] -> [V2] -> [V3] -> [Word16] -> Geometry Geometry3
- module FWGL.Graphics.Color
- data Texture
- textureURL :: String -> Texture
- textureFile :: String -> Texture
- colorTex :: GLES => Color -> Texture
- mkTexture :: GLES => Int -> Int -> [Color] -> Texture
- data V3 = V3 !Float !Float !Float
- pos :: V3 -> Element -> Element
- rotX :: Float -> Element -> Element
- rotY :: Float -> Element -> Element
- rotZ :: Float -> Element -> Element
- rotAA :: V3 -> Float -> Element -> Element
- scale :: Float -> Element -> Element
- scaleV :: V3 -> Element -> Element
- transform :: M4 -> Element -> Element
- data Layer
- elements :: BackendIO => [Element] -> Layer
- view :: BackendIO => M4 -> [Element] -> Layer
- data Program gs is
- layer :: BackendIO => Object DefaultUniforms3D Geometry3 -> Layer
- layerPrg :: (BackendIO, Subset og pg) => Program pg Geometry3 -> Object og Geometry3 -> Layer
- program :: (ValidVertex vgs vis vos, Valid fgs vos [], Equal pgs (Union vgs fgs)) => VertexShader vgs vis vos -> FragmentShader fgs vos -> Program pgs vis
- subLayer :: Int -> Int -> Layer -> (Texture -> [Layer]) -> Layer
- depthSubLayer :: Int -> Int -> Layer -> (Texture -> [Layer]) -> Layer
- data Object gs is
- object :: BackendIO => M4 -> [Element] -> Object DefaultUniforms3D Geometry3
- object1 :: BackendIO => Element -> Object `[Transform3, Texture2]` Geometry3
- object1Trans :: BackendIO => Element -> Object `[Transform3]` Geometry3
- object1Tex :: BackendIO => Element -> Object `[Texture2]` Geometry3
- (~~) :: (Equal gs gs', Equal is is') => Object gs is -> Object gs' is' -> Object (Union gs gs') (Union is is')
- global :: (Typeable g, UniformCPU c g) => g -> c -> Object gs is -> Object (g : gs) is
- globalTexture :: (BackendIO, Typeable g, UniformCPU ActiveTexture g) => g -> Texture -> Object gs is -> Object (g : gs) is
- globalTexSize :: (BackendIO, Typeable g, UniformCPU c g) => g -> Texture -> ((Int, Int) -> c) -> Object gs is -> Object (g : gs) is
- viewObject :: BackendIO => M4 -> Object gs Geometry3 -> Object (View3 : gs) Geometry3
- type DefaultUniforms3D = Uniforms
- data Texture2
- data Transform3
- data View3
- data V4 = V4 !Float !Float !Float !Float
- data M4 = M4 !V4 !V4 !V4 !V4
- mat4 :: (Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float) -> M4
- mul4 :: M4 -> M4 -> M4
- perspectiveMat4 :: Float -> Float -> Float -> Float -> M4
- orthoMat4 :: Float -> Float -> Float -> Float -> Float -> Float -> M4
- cameraMat4 :: V3 -> Float -> Float -> M4
- idMat4 :: M4
- transMat4 :: V3 -> M4
- rotXMat4 :: Float -> M4
- rotYMat4 :: Float -> M4
- rotZMat4 :: Float -> M4
- rotAAMat4 :: V3 -> Float -> M4
- scaleMat4 :: V3 -> M4
Elements
Geometry
:: GLES | |
=> [V3] | List of vertices. |
-> [V2] | List of UV coordinates. |
-> [V3] | List of normals. |
-> [Word16] | Triangles expressed as triples of indices to the three lists above. |
-> Geometry Geometry3 |
Create a 3D Geometry
. The first three lists should have the same length.
Textures
module FWGL.Graphics.Color
textureFile :: String -> Texture
The same as textureURL
.
Creates a Texture
from a list of pixels.
Transformations
data V3
Three-dimensional vector.
Layers
data Layer
An object associated with a program. It can also be a layer included in another.
Element layers
Object layers
data Program gs is
A vertex shader associated with a compatible fragment shader.
program :: (ValidVertex vgs vis vos, Valid fgs vos [], Equal pgs (Union vgs fgs)) => VertexShader vgs vis vos -> FragmentShader fgs vos -> Program pgs vis
Create a Program
from the shaders.
Sublayers
Custom 3D objects
data Object gs is
An object is a set of geometries associated with some uniforms. For
example, if you want to draw a rotating cube, its vertices, normals, etc.
would be the Geometry
, the combination of the geometry and the value of the
model matrix would be the Object
, and the combination of the object with
a Program
would be the Layer
. In fact, Object
s are just descriptions
of the actions to perform to draw something. Instead, the Element types in
FWGL.Graphics.D2 and FWGL.Graphics.D3 represent managed (high level) objects,
and they are ultimately converted to them.
object1 :: BackendIO => Element -> Object `[Transform3, Texture2]` Geometry3
Create a graphical Object
from a single Element
. This lets you set your
own globals individually. If the shader uses the view matrix View3
(e.g.
the default 3D shader), you have to set it with viewObject
.
object1Trans :: BackendIO => Element -> Object `[Transform3]` Geometry3
Like object1
, but it will only set the transformation matrix.
object1Tex :: BackendIO => Element -> Object `[Texture2]` Geometry3
Like 'object1, but it will only set the texture.
(~~) :: (Equal gs gs', Equal is is') => Object gs is -> Object gs' is' -> Object (Union gs gs') (Union is is')
Join two objects.
Globals
global :: (Typeable g, UniformCPU c g) => g -> c -> Object gs is -> Object (g : gs) is
Sets a global variable (uniform) of an object.
globalTexture :: (BackendIO, Typeable g, UniformCPU ActiveTexture g) => g -> Texture -> Object gs is -> Object (g : gs) is
Sets a global (uniform) of an object using a Texture
.
globalTexSize :: (BackendIO, Typeable g, UniformCPU c g) => g -> Texture -> ((Int, Int) -> c) -> Object gs is -> Object (g : gs) is
Sets a global (uniform) of an object using the dimensions of a Texture
.
viewObject :: BackendIO => M4 -> Object gs Geometry3 -> Object (View3 : gs) Geometry3
Set the value of the view matrix of a 3D Object
.
type DefaultUniforms3D = Uniforms
The uniforms used in the default 3D program.
data View3
3D matrices
data V4
Four-dimensional vector.
data M4
4x4 matrix.
Eq M4 | |
Show M4 | |
GLES => UniformCPU M4 M4 | |
GLES => UniformCPU CM4 View3 | |
GLES => UniformCPU CM4 Transform3 |
mat4 :: (Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float, Float) -> M4
Create a 4x4 matrix.
View matrices
4x4 perspective projection matrix.
4x4 orthographic projection matrix.