Add picture shader container datatype

This commit is contained in:
2021-07-28 20:14:54 +02:00
parent a2b94965d7
commit ee553c6e49
9 changed files with 201 additions and 78 deletions
+74
View File
@@ -9,6 +9,7 @@ module Shader.Data
, VShader (..)
, ShaderTexture (..)
, EPrimitiveMode (..)
, PicShads (..)
-- | Lens functions
, vao
, vaoVBO
@@ -27,6 +28,14 @@ module Shader.Data
, vshaderCustomUnis
, vshaderPokeTest
, psPoly
, psPolyz
, psBez
, psText
, psArc
, psEll
-- TODO make lenses for VBO object
-- , textureObject
) where
import Picture.Data
@@ -49,6 +58,7 @@ data VBO = VBO
{ _vbo :: BufferObject
, _vboPointer :: Ptr Float
, _vboAttribSizes :: [Int] -- ^ It is not clear to me if this is necessary to store or not
, _vboStride :: Int
}
data VShader = VShader
{ _vshaderProgram :: Program
@@ -58,6 +68,69 @@ data VShader = VShader
, _vshaderCustomUnis :: [UniformLocation]
, _vshaderPokeTest :: VertexType -> Bool
}
data PicShads a = PicShads
{ _psPoly :: a
, _psPolyz :: a
, _psBez :: a
, _psText :: a
, _psArc :: a
, _psEll :: a
}
-- boilerplate folows
instance Functor PicShads where
fmap f PicShads
{ _psPoly = thePoly
, _psPolyz = thePolyz
, _psBez = theBez
, _psText = theText
, _psArc = theArc
, _psEll = theEll
}
= PicShads
{ _psPoly = f thePoly
, _psPolyz = f thePolyz
, _psBez = f theBez
, _psText = f theText
, _psArc = f theArc
, _psEll = f theEll
}
instance Applicative PicShads where
pure a = PicShads a a a a a a
(<*>) PicShads
{ _psPoly = fPoly
, _psPolyz = fPolyz
, _psBez = fBez
, _psText = fText
, _psArc = fArc
, _psEll = fEll
}
PicShads
{ _psPoly = thePoly
, _psPolyz = thePolyz
, _psBez = theBez
, _psText = theText
, _psArc = theArc
, _psEll = theEll
}
= PicShads
{ _psPoly = fPoly thePoly
, _psPolyz = fPolyz thePolyz
, _psBez = fBez theBez
, _psText = fText theText
, _psArc = fArc theArc
, _psEll = fEll theEll
}
instance Foldable PicShads where
foldr f x PicShads
{ _psPoly = thePoly
, _psPolyz = thePolyz
, _psBez = theBez
, _psText = theText
, _psArc = theArc
, _psEll = theEll
}
= f thePoly . f thePolyz . f theBez . f theText . f theArc $ f theEll x
{- | Datatype containing the necessary information for a single shader. -}
data FullShader = FullShader
@@ -89,3 +162,4 @@ data EPrimitiveMode
makeLenses ''VAO
makeLenses ''FullShader
makeLenses ''VShader
makeLenses ''PicShads