module FWGL.Graphics.D3 (
Element,
cube,
Geometry,
Geometry3,
geom,
mkGeometry3,
module FWGL.Graphics.Color,
Texture,
textureURL,
textureFile,
textureLayer,
C.colorTex,
mkTexture,
V3(..),
pos,
rotX,
rotY,
rotZ,
rotAA,
scale,
scaleV,
transform,
Layer,
elements,
view,
layer,
layerPrg,
Object,
object,
object1,
(C.~~),
C.global,
C.globalTexture,
C.globalTexSize,
viewObject,
DefaultUniforms3D,
Texture2(..),
Transform3(..),
View3(..),
V4(..),
M4(..),
mat4,
mul4,
perspectiveMat4,
idMat4,
transMat4,
rotXMat4,
rotYMat4,
rotZMat4,
rotAAMat4,
scaleMat4
) where
import Control.Applicative
import FWGL.Backend hiding (Texture, Program)
import FWGL.Geometry
import qualified FWGL.Graphics.Custom as C
import FWGL.Graphics.Color
import FWGL.Graphics.Draw
import FWGL.Graphics.Shapes
import FWGL.Graphics.Types
import FWGL.Internal.TList
import FWGL.Shader.Default3D (Texture2, Transform3, View3)
import FWGL.Shader.Program
import FWGL.Graphics.Texture
import FWGL.Vector
data Element = Element Texture (Draw M4) (Geometry Geometry3)
cube :: GLES => Texture -> Element
cube t = Element t (return idMat4) cubeGeometry
geom :: Texture -> Geometry Geometry3 -> Element
geom t = Element t $ return idMat4
object :: BackendIO => M4 -> [Element] -> Object DefaultUniforms3D Geometry3
object m = viewObject m . foldl acc ObjectEmpty
where acc o e = o C.~~ object1 e
object1 :: BackendIO => Element -> Object '[Transform3, Texture2] Geometry3
object1 (Element t m g) = C.globalDraw (undefined :: Transform3) m $
C.globalTexture (undefined :: Texture2) t $
C.static g
elements :: BackendIO => [Element] -> Layer
elements = layer . object idMat4
view :: BackendIO => M4 -> [Element] -> Layer
view m = layer . object m
viewObject :: BackendIO => M4 -> Object gs Geometry3
-> Object (View3 ': gs) Geometry3
viewObject = C.global (undefined :: View3)
layer :: BackendIO => Object DefaultUniforms3D Geometry3 -> Layer
layer = layerPrg defaultProgram3D
layerPrg :: (BackendIO, Subset og pg) => Program pg Geometry3
-> Object og Geometry3 -> Layer
layerPrg = C.layer
pos :: V3 -> Element -> Element
pos v = transform $ transMat4 v
rotX :: Float -> Element -> Element
rotX a = transform $ rotXMat4 a
rotY :: Float -> Element -> Element
rotY a = transform $ rotYMat4 a
rotZ :: Float -> Element -> Element
rotZ a = transform $ rotZMat4 a
rotAA :: V3 -> Float -> Element -> Element
rotAA ax ag = transform $ rotAAMat4 ax ag
scale :: Float -> Element -> Element
scale f = transform $ scaleMat4 (V3 f f f)
scaleV :: V3 -> Element -> Element
scaleV v = transform $ scaleMat4 v
transform :: M4 -> Element -> Element
transform m' (Element t m g) = Element t (mul4 <$> m <*> pure m') g