{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE StrictData #-} {- | Datatypes used to setup and pass data to shaders. -} module Shader.Data ( VAO (..) , VBO (..) , EBO (..) , FullShader (..) , ShaderTexture (..) , EPrimitiveMode (..) -- | Lens functions , vao , vaoVBO , shadProg , shadVAO , shadPrim , shadTex , shadUnis , vbo , vboPtr , vboAttribSizes , vboStride , ebo , eboPtr -- | Synonyms , vert , geom , frag ) where import Graphics.Rendering.OpenGL import Foreign import Control.Lens {- | Datatype containing the necessary information for a single shader. -} data FullShader = FullShader { _shadProg :: Program , _shadVAO :: VAO , _shadPrim :: EPrimitiveMode , _shadTex :: Maybe ShaderTexture , _shadUnis :: [UniformLocation] } {- | 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 , _vboPtr :: Ptr Float , _vboAttribSizes :: [Int] -- ^ It is not clear to me if this is necessary to store or not , _vboStride :: Int } data EBO = EBO { _ebo :: BufferObject , _eboPtr :: Ptr GLushort } {- | 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 -- | Short synonyms for shader types vert, geom, frag :: ShaderType vert = VertexShader geom = GeometryShader frag = FragmentShader makeLenses ''VAO makeLenses ''VBO makeLenses ''FullShader makeLenses ''EBO