module Gelatin.Shaders.Common
( VertexShader
, FragmentShader
, Uniform
, Attribute
, AttributeToggling(..)
, AttributeBuffering(..)
, IsShaderType(..)
, ShaderSteps(..)
) where
import Data.Proxy (Proxy (..))
import Gelatin.Shaders.TypeLevel
data VertexShader
data FragmentShader
data ShaderType = ShaderTypeVertex | ShaderTypeFragment
class IsShaderType a b where
getShaderType :: Proxy a -> b
instance IsShaderType VertexShader ShaderType where
getShaderType _ = ShaderTypeVertex
instance IsShaderType FragmentShader ShaderType where
getShaderType _ = ShaderTypeFragment
instance (IsShaderType t b, IsShaderType ts [b])
=> IsShaderType (t ': ts) [b] where
getShaderType _ = getShaderType (Proxy :: Proxy t) : getShaderType (Proxy :: Proxy ts)
instance IsShaderType '[] [x] where
getShaderType _ = []
data Uniform name val
instance GetLits name String => GetLits (Uniform name val) String where
getSymbols _ = getSymbols (Proxy :: Proxy name)
data Attribute name val loc
instance (GetLits name String, GetLits loc Integer)
=> GetLits (Attribute name val loc) (String, Integer) where
getSymbols _ =
let name = getSymbols (Proxy :: Proxy name)
loc = getSymbols (Proxy :: Proxy loc)
in (name, loc)
data AttributeToggling a
data AttributeBuffering a
data ShaderSteps t v = ShaderSteps { unShaderSteps :: [v] }
class MonadShader a where
data M a :: * -> *
data Program a
readProgram :: (M a) (Program a)
data Uniforms a
updateUniforms :: Uniforms a -> (M a) ()
data Attributes a
enableAttributes :: Attributes a -> (M a) ()
disableAttributes :: Attributes a -> (M a) ()
bufferAttributes :: Attributes a -> (M a) ()