Files
loop/src/Shader/Data.hs
T

75 lines
1.9 KiB
Haskell

{-# LANGUAGE TemplateHaskell #-}
{- |
Datatypes used to setup and pass data to shaders.
-}
module Shader.Data
( VAO (..)
, VBO (..)
, FullShader (..)
, ShaderTexture (..)
, EPrimitiveMode (..)
-- | Lens functions
, vao
, vaoVBO
, shaderProgram
, shaderVAO
, shaderPokeStrategy
, shaderDrawPrimitive
, shaderTexture
, shaderCustomUnis
-- , textureObject
) where
import Picture.Data
import Graphics.Rendering.OpenGL
import Foreign
import Control.Lens
--import Graphics.GL.Types
{- | Vertex array object: contains the reference to the object,
and its buffer targets. -}
data VAO = VAO
{ _vao :: VertexArrayObject
, _vaoVBO :: VBO
}
{- | Vertex buffer object: contains the reference to the object,
a pointer to a location with space that can be written to the buffer,
and a list of attribute pointer sizes.
Vertex attributes are interleaved within the vbo. -}
data VBO = VBO
{ _vbo :: BufferObject
, _vboPointer :: Ptr Float
, _vboAttribSizes :: [Int] -- ^ It is not clear to me if this is necessary to store or not
}
{- | Datatype containing the necessary information for a single shader. -}
data FullShader = FullShader
{ _shaderProgram :: Program
, _shaderVAO :: VAO
, _shaderPokeStrategy :: RenderType -> [[Float]]-- -> F.FoldM IO RenderType Int
, _shaderDrawPrimitive :: EPrimitiveMode
, _shaderTexture :: Maybe ShaderTexture
, _shaderCustomUnis :: [UniformLocation]
}
{- | Datatype containing the reference to a texture object. -}
newtype ShaderTexture = ShaderTexture
{ _textureObject :: TextureObject }
data EPrimitiveMode
= EPoints
| ELines
| ELinesAdjacency
| ELineLoop
| ELineStrip
| ETriangles
| ETriangleStrip
| ETriangleFan
| EQuads
| EQuadStrip
| EPolygon
| EPatches
makeLenses ''VAO
makeLenses ''FullShader