Copyright | (c) Simeon Krastnikov 2022-2023 |
---|---|
License | MIT |
Maintainer | Simeon Krastnikov <skrastnikov@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module exports everything that comprises the core language.
It is best used with the following extensions enabled:
GADTs
, DataKinds
, ViewPatterns
, FlexibleContexts
.
Note that quite a few of the exported functions clash with unrelated
ones from Prelude (max
, length
, mod
, any
, etc.) or class methods
with identical behaviour (abs
, sin
, etc.), in an effort to prioritize
consistency with GLSL function naming.
In summary, this module can be imported as follows:
{-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE FlexibleContexts #-} import Prelude hiding (max, sin, cos, ...) import Graphics.HaGL
HaGL expressions have the type GLExpr
(d :: GLDomain
) t,
where d
is the domain of computation and t
is the underlying numeric type,
which is always an instance of GLType
. Here are some example expressions:
-- A vertex attribute constructed from its input values on three vertices x :: GLExpr VertexDomain Float x = vert [-1, 0, 1] -- Numeric operators and functions like (+) and sin can handle generic -- expressions. Note that in this example the domain of the inputs to -- these functions is VertexDomain, so we know that these functions will -- be computed in a vertex shader. y :: GLExpr VertexDomain Float y = sin (2 * x + 1) -- 'frag x' is a a fragment variable corresponding to an interpolation of -- the value of x at the vertices that define its containing primitive. -- Because it has the type 'GLExpr FragmentDomain Float', the addition -- below will be computed in a fragment shader. z :: GLExpr FragmentDomain Float z = frag x + 3 -- 'time' is a built-in I/O variable and as such it is computed on the CPU time :: GLExpr HostDomain Float -- We can use 'uniform' to lift a host variable to an arbitrary domain -- Here 'uniform time' is inferred to have type 'GLExpr VertexDomain Float': yPlusTime :: GLExpr VertexDomain Float yPlusTime = y + uniform time -- Here 'uniform time' is inferred to be of type 'GLExpr FragmentDomain Float': zPlusTime :: GLExpr FragmentDomain Float zPlusTime = z + uniform time -- A generic floating-point vector of length 4 v :: GLExpr d (Vec 4 Float) v = vec4 1 1 1 1 -- A vector can be initialized from a numeric literal, so long as its -- underlying type 'Vec n t' is specified or can be inferred. -- Here is another way to define the same vector v: v' :: GLExpr d (Vec 4 Float) v' = 1 -- Matrices are constructed from their columns: m :: GLExpr d (Mat 2 3 Float) m = mat2x3 (vec2 1 2) (vec2 3 4) (vec2 5 6) -- Operators like (.+) and (.*) act component-wise on vectors and matrices: _ = m .+ m .== mat2x3 (vec2 2 4) (vec2 6 8) (vec2 10 12) -- Non-boolean primitives and vectors over such types are instances of Num; -- in such cases Num methods like (+) can be used instead. _ = vec2 1 1 + 1 .== vec2 2 2 -- The operator (.#) performs scalar multiplication: _ = 3 .# v _ = 3 .# m -- The operator (.@) performs matrix multiplication -- (including matrix-vector multiplication): m1 :: GLExpr d (Mat 2 3 Float) m1 = ... m2 :: GLExpr d (Mat 3 4 Float) m2 = ... m1m2 :: GLExpr d (Mat 2 4 Float) m1m2 = m1 .@ m2 -- All multiplications here will take place in a vertex shader: m1m2v :: GLExpr VertexDomain (Vec 2 Float) m1m2v = m1m2 .@ v -- The inferred type of m1m2 in this expression is -- 'GLExpr HostDomain (Mat 2 4 Float)' so the multiplication of m1 and m2 -- will take place on the CPU. -- The inferred type of uniform m1m2 is 'GLExpr VertexDomain (Mat 2 4 Float)' -- and that of v is 'GLExpr VertexDomain (Vec 2 Float)' so their -- multiplication will take place in a vertex shader. m1m2v' :: GLExpr VertexDomain (Vec 2 Float) m1m2v' = uniform m1m2 .@ v
GLExpr
s can be used to construct GLObj
s, which being instances
of Drawable
can be interpreted by a given Backend
using draw
.
For example:
-- initialize pos from the vertices of some 3D object pos :: GLExpr VertexDomain (Vec 4 Float) pos = vert [vec4 1 0 0 1, ...] red :: GLExpr FragmentDomain (Vec 4 Float) red = vec4 1 0 0 1 redObj :: GLObj redObj = GLObj { primitiveMode = TriangleStrip, indices = Nothing, position = pos, color = red, discardWhen = False } -- or equivalently, redObj' :: GLObj redObj' = triangleStrip { position = pos, color = red } -- we can now draw the object main :: IO () main = draw GlutBackend redObj
A complete set of examples explained in more depth can be found in the "Getting Started" guide.
Synopsis
- class (Eq t, Show t) => GLType t
- data Float
- data Double
- data Int
- type UInt = Word32
- data Bool
- data Mat (p :: Nat) (q :: Nat) (t :: *)
- type Vec n t = Mat n 1 t
- type family GLElt t where ...
- fromMapping :: forall p q t. (KnownNat p, KnownNat q) => ((Int, Int) -> t) -> Mat p q t
- fromList :: forall p q t. (KnownNat p, KnownNat q) => [t] -> Mat p q t
- class (GLType t, Storable t, Enum t, Eq t, Ord t) => GLPrim t
- class (GLPrim t, Storable t, Enum t, Eq t, Ord t) => GLSingle t
- class (GLPrim t, Num t) => GLNumeric t
- class GLNumeric t => GLSigned t
- class (GLSigned t, RealFrac t, Floating t) => GLFloating t
- class GLSigned t => GLSingleNumeric t
- class (GLPrim t, Integral t, Bits t) => GLInteger t
- class GLType t => GLPrimOrVec t
- class (GLPrimOrVec t, Storable (StoreElt t)) => GLInputType t
- class GLInputType t => GLSupportsSmoothInterp t
- class (GLType t, Integral (GLElt t), Bits (GLElt t)) => GLSupportsBitwiseOps t
- data GLExpr (d :: GLDomain) (t :: *)
- data GLDomain
- type ConstExpr = GLExpr ConstDomain
- type HostExpr = GLExpr HostDomain
- type VertExpr = GLExpr VertexDomain
- type FragExpr = GLExpr FragmentDomain
- cnst :: GLType t => ConstExpr t -> GLExpr d t
- true :: GLExpr d Bool
- false :: GLExpr d Bool
- uniform :: GLType t => HostExpr t -> GLExpr d t
- prec :: GLType t => HostExpr t -> HostExpr t -> HostExpr t
- vert :: GLInputType t => [ConstExpr t] -> VertExpr t
- frag :: GLSupportsSmoothInterp t => VertExpr t -> FragExpr t
- noperspFrag :: GLSupportsSmoothInterp t => GLInputType t => VertExpr t -> FragExpr t
- flatFrag :: GLInputType t => VertExpr t -> FragExpr t
- vec2 :: forall {t1} {d :: GLDomain}. GLType (Mat 2 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 2 1 t1)
- vec3 :: forall {t1} {d :: GLDomain}. GLType (Mat 3 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 3 1 t1)
- vec4 :: forall {t1} {d :: GLDomain}. GLType (Mat 4 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 4 1 t1)
- mat2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 2 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 2 t1)
- mat3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 3 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 3 t1)
- mat4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 4 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 4 t1)
- mat2x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 2 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 2 t1)
- mat2x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 3 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 3 t1)
- mat2x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 4 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 4 t1)
- mat3x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 2 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 2 t1)
- mat3x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 3 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 3 t1)
- mat3x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 4 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 4 t1)
- mat4x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 2 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 2 t1)
- mat4x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 3 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 3 t1)
- mat4x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 4 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 4 t1)
- pre :: forall {n :: Nat} {t1} {d :: GLDomain}. (GLType (Vec n t1), GLType (Mat (n + 1) 1 t1)) => GLExpr d t1 -> GLExpr d (Vec n t1) -> GLExpr d (Mat (n + 1) 1 t1)
- app :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLType t1, GLType (Vec n t1), GLType (Mat (n + 1) 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d t1 -> GLExpr d (Mat (n + 1) 1 t1)
- ($-) :: forall {m :: Nat} {t1} {n :: Nat} {d :: GLDomain}. (GLType (Vec m t1), GLType (Vec n t1), GLType (Mat (m + n) 1 t1)) => GLExpr d (Vec m t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat (m + n) 1 t1)
- array :: GLType [t1] => [GLExpr 'HostDomain t1] -> GLExpr 'HostDomain [t1]
- class Deconstructible t where
- x_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 1 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t
- y_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t
- z_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t
- w_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t
- xy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- xz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- xw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- yx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- yz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- yw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- zx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- zy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- zw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- wx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- wy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- wz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1)
- xyz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- xyw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- xzy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- xzw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- xwy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- xwz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- yxz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- yxw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- yzx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- yzw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- ywx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- ywz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zxy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zxw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zyx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zyw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zwx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- zwy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wxy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wxz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wyx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wyz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wzx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- wzy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1)
- col0 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 1 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1)
- col1 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1)
- col2 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1)
- col3 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1)
- (.!) :: forall {t} {d :: GLDomain}. (GLType t, GLType [t]) => GLExpr d [t] -> GLExpr d Int -> GLExpr d t
- cast :: forall {t1} {t} {d :: GLDomain}. (GLPrim t1, GLPrim t) => GLExpr d t1 -> GLExpr d t
- matCast :: forall {t1} {t2} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLPrim t1, GLPrim t2, KnownNat p, KnownNat q, GLType (Mat p q t2)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t2)
- (.+) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.-) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.*) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- (./) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.%) :: forall {t} {d :: GLDomain}. (GLInteger (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.#) :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLNumeric t1, GLType (Mat p q t1)) => GLExpr d t1 -> GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1)
- (.@) :: forall {t1} {p :: Nat} {r :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p r t1), GLType (Mat p q t1), GLType (Mat q r t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat q r t1) -> GLExpr d (Mat p r t1)
- neg :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t
- (.<) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (.<=) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (.>) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (.>=) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (.==) :: forall {t1} {d :: GLDomain}. GLType t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (./=) :: forall {t1} {d :: GLDomain}. GLType t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool
- (.&&) :: forall {d :: GLDomain}. GLExpr d Bool -> GLExpr d Bool -> GLExpr d Bool
- (.||) :: forall {d :: GLDomain}. GLExpr d Bool -> GLExpr d Bool -> GLExpr d Bool
- (.^^) :: forall {d :: GLDomain}. GLExpr d Bool -> GLExpr d Bool -> GLExpr d Bool
- nt :: forall {d :: GLDomain}. GLExpr d Bool -> GLExpr d Bool
- cond :: forall {t} {d :: GLDomain}. GLType t => GLExpr d Bool -> GLExpr d t -> GLExpr d t -> GLExpr d t
- (.<<) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.>>) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.&) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.|) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t
- (.^) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t
- compl :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t
- radians :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- degrees :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- sin :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- cos :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- tan :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- asin :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- acos :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- atan :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- sinh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- cosh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- tanh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- asinh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- acosh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- atanh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- pow :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- exp :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- log :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- exp2 :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- log2 :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- sqrt :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- inversesqrt :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- abs :: forall {t} {d :: GLDomain}. (GLSigned (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- sign :: forall {t} {d :: GLDomain}. (GLSigned (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- floor :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- trunc :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- round :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- roundEven :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- ceil :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- fract :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t
- mod :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- min :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- max :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- clamp :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t
- mix :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t
- step :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t
- smoothstep :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t
- length :: forall {t} {d :: GLDomain} {n :: Nat}. GLFloating t => GLExpr d (Vec n t) -> GLExpr d t
- distance :: forall {t} {d :: GLDomain} {n :: Nat}. GLFloating t => GLExpr d (Vec n t) -> GLExpr d (Vec n t) -> GLExpr d t
- dot :: forall {t} {n :: Nat} {d :: GLDomain}. (GLFloating t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d (Vec n t) -> GLExpr d t
- cross :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Mat 3 1 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 1 t1)
- normalize :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1)
- faceforward :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1)
- reflect :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1)
- refract :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d t1 -> GLExpr d (Mat n 1 t1)
- matrixCompMult :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p q t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1)
- outerProduct :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p q t1), GLType (Vec q t1)) => GLExpr d (Vec p t1) -> GLExpr d (Vec q t1) -> GLExpr d (Mat p q t1)
- transpose :: forall {t1} {q :: Nat} {p :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat q p t1), GLType (Mat p q t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat q p t1)
- determinant :: forall {p :: Nat} {d :: GLDomain}. GLType (Mat p p Float) => GLExpr d (Mat p p Float) -> GLExpr d Float
- inverse :: forall {p :: Nat} {d :: GLDomain}. GLType (Mat p p Float) => GLExpr d (Mat p p Float) -> GLExpr d (Mat p p Float)
- lessThan :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- lessThanEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- greaterThan :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- greaterThanEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- equal :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingle t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- notEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingle t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool)
- any :: forall {n :: Nat} {d :: GLDomain}. GLType (Vec n Bool) => GLExpr d (Vec n Bool) -> GLExpr d Bool
- all :: forall {n :: Nat} {d :: GLDomain}. GLType (Vec n Bool) => GLExpr d (Vec n Bool) -> GLExpr d Bool
- not :: forall {n :: Nat} {d :: GLDomain}. GLType (Mat n 1 Bool) => GLExpr d (Vec n Bool) -> GLExpr d (Mat n 1 Bool)
- glFunc1 :: (GLType t, GLType t1) => (GLExpr d t1 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t
- glFunc2 :: (GLType t, GLType t1, GLType t2) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t
- glFunc3 :: (GLType t, GLType t1, GLType t2, GLType t3) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t
- glFunc4 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t
- glFunc5 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t
- glFunc6 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5, GLType t6) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t6 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t6 -> GLExpr d t
- glLift0 :: GLType t => t -> GLExpr 'HostDomain t
- glLift1 :: (GLType t, GLType t1) => (t1 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t
- glLift2 :: (GLType t, GLType t1, GLType t2) => (t1 -> t2 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t
- glLift3 :: (GLType t, GLType t1, GLType t2, GLType t3) => (t1 -> t2 -> t3 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t
- glLift4 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4) => (t1 -> t2 -> t3 -> t4 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t
- glLift5 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5) => (t1 -> t2 -> t3 -> t4 -> t5 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t5 -> GLExpr 'HostDomain t
- glLift6 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5, GLType t6) => (t1 -> t2 -> t3 -> t4 -> t5 -> t6 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t5 -> GLExpr 'HostDomain t6 -> GLExpr 'HostDomain t
- time :: HostExpr Float
- mouseLeft :: HostExpr Bool
- mouseRight :: HostExpr Bool
- mouseWheel :: HostExpr Float
- mouseX :: HostExpr Float
- mouseY :: HostExpr Float
- mousePos :: HostExpr (Vec 2 Float)
- class Drawable a where
- data GLObj = GLObj {}
- type PrimitiveMode = PrimitiveMode
- points :: GLObj
- lines :: GLObj
- lineLoop :: GLObj
- lineStrip :: GLObj
- triangles :: GLObj
- triangleStrip :: GLObj
- triangleFan :: GLObj
- quads :: GLObj
- quadStrip :: GLObj
- polygon :: GLObj
- data Backend = GlutBackend GlutOptions
- data GlutOptions = GlutOptions {}
- data GlutRunMode
- drawGlut :: Drawable a => a -> IO ()
- drawGlutCustom :: Drawable a => GlutOptions -> a -> IO ()
- defaultGlutOptions :: GlutOptions
GLType
class (Eq t, Show t) => GLType t Source #
The class of base raw types. Users should not and need not implement any instances of this class.
showGlslType, showGlslVal, glMap, glZipWith, glZipWith3, eltSize, numComponents, arrayLen, getGlslType, uniformSet
Instances
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]
.
The exact range for a given implementation can be determined by using
minBound
and maxBound
from the Bounded
class.
Instances
Instances
data Mat (p :: Nat) (q :: Nat) (t :: *) Source #
A matrix with p
rows, q
columns, and element type t
Instances
Raw vector/matrix constructors
Though raw types are not usually constructed directly, the following functions can be used for loading data from externally computed arrays via lifts.
fromMapping :: forall p q t. (KnownNat p, KnownNat q) => ((Int, Int) -> t) -> Mat p q t Source #
Construct a matrix from a mapping that maps indices (i, j)
to
the element at row i
and column j
fromList :: forall p q t. (KnownNat p, KnownNat q) => [t] -> Mat p q t Source #
Construct a matrix from a list of the matrix elements in row-major order
Subclasses of GLType
class (GLType t, Storable t, Enum t, Eq t, Ord t) => GLPrim t Source #
Any primitive type
glCast
Instances
GLPrim UInt Source # | |
Defined in Graphics.HaGL.GLType | |
GLPrim Bool Source # | |
Defined in Graphics.HaGL.GLType | |
GLPrim Double Source # | |
Defined in Graphics.HaGL.GLType | |
GLPrim Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLPrim Int Source # | |
Defined in Graphics.HaGL.GLType |
class (GLPrim t, Storable t, Enum t, Eq t, Ord t) => GLSingle t Source #
Any single-precision primitive type
Instances
GLSingle UInt Source # | |
Defined in Graphics.HaGL.GLType | |
GLSingle Bool Source # | |
Defined in Graphics.HaGL.GLType | |
GLSingle Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLSingle Int Source # | |
Defined in Graphics.HaGL.GLType |
class (GLPrim t, Num t) => GLNumeric t Source #
Any numeric primitive type
genDiv
Instances
GLNumeric UInt Source # | |
Defined in Graphics.HaGL.GLType | |
GLNumeric Double Source # | |
Defined in Graphics.HaGL.GLType | |
GLNumeric Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLNumeric Int Source # | |
Defined in Graphics.HaGL.GLType |
class GLNumeric t => GLSigned t Source #
Any signed primitive type
Instances
GLSigned Double Source # | |
Defined in Graphics.HaGL.GLType | |
GLSigned Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLSigned Int Source # | |
Defined in Graphics.HaGL.GLType |
class (GLSigned t, RealFrac t, Floating t) => GLFloating t Source #
Any single- or double-precision floating-point type
Instances
GLFloating Double Source # | |
Defined in Graphics.HaGL.GLType | |
GLFloating Float Source # | |
Defined in Graphics.HaGL.GLType |
class GLSigned t => GLSingleNumeric t Source #
Any single-precision signed primitive type
Instances
GLSingleNumeric Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLSingleNumeric Int Source # | |
Defined in Graphics.HaGL.GLType |
class (GLPrim t, Integral t, Bits t) => GLInteger t Source #
Any signed or unsigned integer type
Instances
GLInteger UInt Source # | |
Defined in Graphics.HaGL.GLType | |
GLInteger Int Source # | |
Defined in Graphics.HaGL.GLType |
class GLType t => GLPrimOrVec t Source #
A primitive type or a vector type
Instances
class (GLPrimOrVec t, Storable (StoreElt t)) => GLInputType t Source #
The underlying type of a vertex input variable. Double-precision types are currently not permitted due to an issue in the OpenGL bindings.
toStorableList
Instances
class GLInputType t => GLSupportsSmoothInterp t Source #
Any type whose values can be interpolated smoothly when constructing a fragment variable
Instances
GLSupportsSmoothInterp Float Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsSmoothInterp (Vec 2 Float) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsSmoothInterp (Vec 3 Float) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsSmoothInterp (Vec 4 Float) Source # | |
Defined in Graphics.HaGL.GLType |
class (GLType t, Integral (GLElt t), Bits (GLElt t)) => GLSupportsBitwiseOps t Source #
Any type which supports bitwise operations
Instances
GLSupportsBitwiseOps UInt Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps Int Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 2 UInt) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 2 Int) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 3 UInt) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 3 Int) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 4 UInt) Source # | |
Defined in Graphics.HaGL.GLType | |
GLSupportsBitwiseOps (Vec 4 Int) Source # | |
Defined in Graphics.HaGL.GLType |
GLExpr
A HaGL expression can be created in one of the following ways:
- Using one of the HaGL-specific constructors
- Directly from a numeric literal, if its underlying type
t
is one ofInt
,UInt
,Float
,Double
, or aVec
of one of these types. (A vector initialized from a valuec
is the vector with all elements equal to c.) - Through the application of built-in operators and functions
data GLExpr (d :: GLDomain) (t :: *) Source #
A generic HaGL expression with domain of computation d
and underlying type t
Instances
A label for the domain where a given computation make take place
ConstDomain | Labels a constant value computed on the host CPU |
HostDomain | Labels a potentially I/O-dependent value computed on the host CPU |
VertexDomain | Labels a vertex shader variable |
FragmentDomain | Labels a fragment shader variable |
type ConstExpr = GLExpr ConstDomain Source #
type HostExpr = GLExpr HostDomain Source #
type VertExpr = GLExpr VertexDomain Source #
type FragExpr = GLExpr FragmentDomain Source #
Constructors
cnst :: GLType t => ConstExpr t -> GLExpr d t Source #
Construct a GLExpr
from a raw type. Rarely useful as this can
be done implicitly; e.g., from a numeric literal.
uniform :: GLType t => HostExpr t -> GLExpr d t Source #
Lift a HostExpr
to an arbitrary GLExpr
whose value is the same across
any primitive processed in a shader, if used in the context of one
prec :: GLType t => HostExpr t -> HostExpr t -> HostExpr t Source #
prec x0 x
is used to obtain a reference to the value x
one "time-step"
in the past, or x0
at the zero-th point in time. The prec
operator is
usually used to define expressions recurrently; for example:
let x = prec 0 (x + 1)
counts the total number of points in time. The
interpretation of a time-step in a given backend is normally an interval
that is on average equal to the length of time between two redraws.
vert :: GLInputType t => [ConstExpr t] -> VertExpr t Source #
A vertex input variable (attribute) constructed from a stream of per-vertex
data. The number of vertices (the length of the stream) should be consistent
across all vertex attributes used to construct a given GLObj
.
frag :: GLSupportsSmoothInterp t => VertExpr t -> FragExpr t Source #
A fragment input variable constructed from the output data of a vertex variable, interpolated in a perspective-correct manner over the primitive being processed
noperspFrag :: GLSupportsSmoothInterp t => GLInputType t => VertExpr t -> FragExpr t Source #
A fragment input variable constructed from the output data of a vertex variable, interpolated linearly across the primitive being processed
flatFrag :: GLInputType t => VertExpr t -> FragExpr t Source #
A fragment input variable constructed from the output data of a vertex variable, having the same value across the primitive being processed (cf. the OpenGL API for which vertex is used to determine its value)
Vector, matrix, and array constructors
A constructor of the form vecn creates a column vector with n components; a constructor of the form matpxq creates a matrix with p rows and q columns (matp is an alias for matpxp).
vec2 :: forall {t1} {d :: GLDomain}. GLType (Mat 2 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 2 1 t1) Source #
vec3 :: forall {t1} {d :: GLDomain}. GLType (Mat 3 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 3 1 t1) Source #
vec4 :: forall {t1} {d :: GLDomain}. GLType (Mat 4 1 t1) => GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d t1 -> GLExpr d (Mat 4 1 t1) Source #
mat2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 2 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 2 t1) Source #
mat3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 3 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 3 t1) Source #
mat4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 4 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 4 t1) Source #
mat2x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 2 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 2 t1) Source #
mat2x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 3 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 3 t1) Source #
mat2x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 2 t1), GLType (Mat 2 4 t1)) => GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Vec 2 t1) -> GLExpr d (Mat 2 4 t1) Source #
mat3x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 2 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 2 t1) Source #
mat3x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 3 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 3 t1) Source #
mat3x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 3 t1), GLType (Mat 3 4 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 4 t1) Source #
mat4x2 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 2 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 2 t1) Source #
mat4x3 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 3 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 3 t1) Source #
mat4x4 :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Vec 4 t1), GLType (Mat 4 4 t1)) => GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Vec 4 t1) -> GLExpr d (Mat 4 4 t1) Source #
pre :: forall {n :: Nat} {t1} {d :: GLDomain}. (GLType (Vec n t1), GLType (Mat (n + 1) 1 t1)) => GLExpr d t1 -> GLExpr d (Vec n t1) -> GLExpr d (Mat (n + 1) 1 t1) Source #
Extend a vector by prepending an element
app :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLType t1, GLType (Vec n t1), GLType (Mat (n + 1) 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d t1 -> GLExpr d (Mat (n + 1) 1 t1) Source #
Extend a vector by appending an element
($-) :: forall {m :: Nat} {t1} {n :: Nat} {d :: GLDomain}. (GLType (Vec m t1), GLType (Vec n t1), GLType (Mat (m + n) 1 t1)) => GLExpr d (Vec m t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat (m + n) 1 t1) infixr 8 Source #
Concatenate two vectors together
array :: GLType [t1] => [GLExpr 'HostDomain t1] -> GLExpr 'HostDomain [t1] Source #
Create an array from a list of HostExpr
s
Deconstruction and indexing
To deconstruct a vector into a tuple of primitive elements or to
deconstruct a matrix into a tuple of column vectors use decon
. This
approach pairs particularly well with view patterns:
vec2Flip :: GLExpr d (Vec 2 t) -> GLExpr d (Vec 2 t) vec2Flip (decon v2 -> (v1, v2)) = vec2 v2 v1
Alternatively, with the synonyms x
, y
, z
, w
, referring to the
components of a vector in that order, projection functions consisting of
an ordered selection of such names followed by an underscore (e.g., xyz_
),
can be used to extract the corresponding components. For matrices, the
projection functions are of the form coln. Note that the types of these
functions constrains the length of their input so that the operation is
well-defined.
class Deconstructible t where Source #
An expression that can be deconstructed into its components
Instances
(GLPrim t, GLType (Mat p 2 t), GLType (Vec p t)) => Deconstructible (GLExpr d (Mat p 2 t)) Source # | |
(GLPrim t, GLType (Mat p 3 t), GLType (Vec p t)) => Deconstructible (GLExpr d (Mat p 3 t)) Source # | |
(GLPrim t, GLType (Mat p 4 t), GLType (Vec p t)) => Deconstructible (GLExpr d (Mat p 4 t)) Source # | |
(GLPrim t, GLType (Vec 2 t)) => Deconstructible (GLExpr d (Vec 2 t)) Source # | |
(GLPrim t, GLType (Vec 3 t)) => Deconstructible (GLExpr d (Vec 3 t)) Source # | |
(GLPrim t, GLType (Vec 4 t)) => Deconstructible (GLExpr d (Vec 4 t)) Source # | |
x_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 1 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t Source #
y_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t Source #
z_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t Source #
w_ :: forall {n :: Nat} {t} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d t Source #
xy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
xz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
xw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
yx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
yz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
yw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
zx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
zy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
zw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
wx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
wy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
wz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 2 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 2 1 t1) Source #
xyz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
xyw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
xzy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
xzw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
xwy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
xwz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
yxz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
yxw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
yzx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
yzw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
ywx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
ywz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zxy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zxw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zyx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zyw_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zwx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
zwy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wxy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wxz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wyx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wyz_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wzx_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
wzy_ :: forall {n :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 n) 'True 'True 'False ~ 'True, GLType (Vec n t1), GLType (Mat 3 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat 3 1 t1) Source #
col0 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 1 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1) Source #
The first column of a matrix
col1 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 2 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1) Source #
The second column of a matrix
col2 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 3 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1) Source #
The third column of a matrix
col3 :: forall {c :: Nat} {r :: Nat} {t1} {d :: GLDomain}. (OrdCond (CmpNat 4 c) 'True 'True 'False ~ 'True, GLType (Mat r c t1), GLType (Mat r 1 t1)) => GLExpr d (Mat r c t1) -> GLExpr d (Mat r 1 t1) Source #
The fourth column of a matrix
(.!) :: forall {t} {d :: GLDomain}. (GLType t, GLType [t]) => GLExpr d [t] -> GLExpr d Int -> GLExpr d t Source #
Array index operator, returning the i
-th (0-indexed) element of the array
Type conversion
cast :: forall {t1} {t} {d :: GLDomain}. (GLPrim t1, GLPrim t) => GLExpr d t1 -> GLExpr d t Source #
Coerce the primitive type of a value to arbitrary primitive type
matCast :: forall {t1} {t2} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLPrim t1, GLPrim t2, KnownNat p, KnownNat q, GLType (Mat p q t2)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t2) Source #
Coerce the element type of a matrix to an arbitrary primitive type
Built-in operators and functions
Most definitions here strive to be consistent with the corresponding built-in functions provided by GLSL (cf. The OpenGL Shading Language, Version 4.60.7), in terms of semantics and typing constraints. Some notable exceptions to this rule are:
- Typing restrictions may be stricter to prevent what would otherwise be runtime errors; for example, matrix multiplication is only defined on matrices with the correct dimensions.
- The operators
(+)
,(-)
,(*)
, as well as the functionnegate
, being methods ofNum
, are only supported on expressions where the underlying type is one ofInt
,UInt
,Float
,Double
, or a vector of one of these types. To perform these operations component-wise on matrices use the operators(.+)
,(.-)
,(.*)
, or the functionneg
respectively. - The operator
(/)
is only supported when the underlying type isFloat
orDouble
. The more general operator(./)
additionally supports integer and component-wise division. - The operator
(.%)
is the modulo operation on integers or integer-valued vectors. - The operator
(.#)
is used for scalar multiplication. - The operator
(.@)
is used for matrix (including matrix-vector) multiplication. - All boolean and bitwise operators are also prefixed with a single dot:
(.==)
,(.<)
,(.&&)
,(.&)
, etc.
Arithmetic operators
(.+) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 6 Source #
(.-) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 6 Source #
(.*) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 7 Source #
(./) :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 7 Source #
(.%) :: forall {t} {d :: GLDomain}. (GLInteger (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 7 Source #
(.#) :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLNumeric t1, GLType (Mat p q t1)) => GLExpr d t1 -> GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1) infixl 7 Source #
Scalar multiplication
(.@) :: forall {t1} {p :: Nat} {r :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p r t1), GLType (Mat p q t1), GLType (Mat q r t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat q r t1) -> GLExpr d (Mat p r t1) infixl 7 Source #
Matrix multiplication
neg :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLType t) => GLExpr d t -> GLExpr d t Source #
Arithmetic negation
Boolean operators and comparison functions
(.<) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
(.<=) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
(.>) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
(.>=) :: forall {t1} {d :: GLDomain}. GLNumeric t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
(.==) :: forall {t1} {d :: GLDomain}. GLType t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
(./=) :: forall {t1} {d :: GLDomain}. GLType t1 => GLExpr d t1 -> GLExpr d t1 -> GLExpr d Bool infix 4 Source #
cond :: forall {t} {d :: GLDomain}. GLType t => GLExpr d Bool -> GLExpr d t -> GLExpr d t -> GLExpr d t Source #
Conditional operator, evaluating and returning its second or third argument if the first evaluates to true or false, respectively
Bitwise operators
(.<<) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 5 Source #
(.>>) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 5 Source #
(.&) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 3 Source #
(.|) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 1 Source #
(.^) :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t -> GLExpr d t infixl 2 Source #
compl :: forall {t} {d :: GLDomain}. GLSupportsBitwiseOps t => GLExpr d t -> GLExpr d t Source #
One's complement
Angle and trigonometry functions
radians :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
degrees :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
sin :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
cos :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
tan :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
asin :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
acos :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
atan :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
sinh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
cosh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
tanh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
asinh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
acosh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
atanh :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
Exponential functions
pow :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t Source #
exp :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
log :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
exp2 :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
log2 :: forall {t} {d :: GLDomain}. (GLElt t ~ Float, GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
sqrt :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
inversesqrt :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
Common functions
abs :: forall {t} {d :: GLDomain}. (GLSigned (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
sign :: forall {t} {d :: GLDomain}. (GLSigned (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
floor :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
trunc :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
round :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
roundEven :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
ceil :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
fract :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t Source #
mod :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t Source #
min :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t Source #
max :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t Source #
clamp :: forall {t} {d :: GLDomain}. (GLNumeric (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t Source #
mix :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t Source #
step :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t Source #
smoothstep :: forall {t} {d :: GLDomain}. (GLFloating (GLElt t), GLPrimOrVec t) => GLExpr d t -> GLExpr d t -> GLExpr d t -> GLExpr d t Source #
Geometric functions
length :: forall {t} {d :: GLDomain} {n :: Nat}. GLFloating t => GLExpr d (Vec n t) -> GLExpr d t Source #
distance :: forall {t} {d :: GLDomain} {n :: Nat}. GLFloating t => GLExpr d (Vec n t) -> GLExpr d (Vec n t) -> GLExpr d t Source #
dot :: forall {t} {n :: Nat} {d :: GLDomain}. (GLFloating t, GLType (Vec n t)) => GLExpr d (Vec n t) -> GLExpr d (Vec n t) -> GLExpr d t Source #
cross :: forall {t1} {d :: GLDomain}. (GLFloating t1, GLType (Mat 3 1 t1)) => GLExpr d (Vec 3 t1) -> GLExpr d (Vec 3 t1) -> GLExpr d (Mat 3 1 t1) Source #
normalize :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1) Source #
faceforward :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1) Source #
reflect :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 t1) Source #
refract :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLFloating t1, KnownNat n, GLType (Mat n 1 t1)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d t1 -> GLExpr d (Mat n 1 t1) Source #
Matrix functions
matrixCompMult :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p q t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1) -> GLExpr d (Mat p q t1) Source #
outerProduct :: forall {t1} {p :: Nat} {q :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat p q t1), GLType (Vec q t1)) => GLExpr d (Vec p t1) -> GLExpr d (Vec q t1) -> GLExpr d (Mat p q t1) Source #
transpose :: forall {t1} {q :: Nat} {p :: Nat} {d :: GLDomain}. (GLFloating t1, GLType (Mat q p t1), GLType (Mat p q t1)) => GLExpr d (Mat p q t1) -> GLExpr d (Mat q p t1) Source #
determinant :: forall {p :: Nat} {d :: GLDomain}. GLType (Mat p p Float) => GLExpr d (Mat p p Float) -> GLExpr d Float Source #
inverse :: forall {p :: Nat} {d :: GLDomain}. GLType (Mat p p Float) => GLExpr d (Mat p p Float) -> GLExpr d (Mat p p Float) Source #
Vector relational functions
lessThan :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
lessThanEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
greaterThan :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
greaterThanEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingleNumeric t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
equal :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingle t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
notEqual :: forall {t1} {n :: Nat} {d :: GLDomain}. (GLSingle t1, KnownNat n, GLType (Mat n 1 Bool)) => GLExpr d (Vec n t1) -> GLExpr d (Vec n t1) -> GLExpr d (Mat n 1 Bool) Source #
any :: forall {n :: Nat} {d :: GLDomain}. GLType (Vec n Bool) => GLExpr d (Vec n Bool) -> GLExpr d Bool Source #
all :: forall {n :: Nat} {d :: GLDomain}. GLType (Vec n Bool) => GLExpr d (Vec n Bool) -> GLExpr d Bool Source #
not :: forall {n :: Nat} {d :: GLDomain}. GLType (Mat n 1 Bool) => GLExpr d (Vec n Bool) -> GLExpr d (Mat n 1 Bool) Source #
Custom function support
An n-ary f
function on GLExpr
's can be transported to an arbitrary
domain using glFuncn
. That is, glFuncn f
will take in the same
arguments as f but will be evaluated in the domain of its return type
(in contrast to f
, which being a native Haskell function, will always
be evaluated on the CPU).
However, due to the fact that GLSL does not allow recursion, attempting
to call glFuncn f
, where f
is defined recursively (or mutually
recursively in terms of other functions) will generally result in an
exception being thrown. The one case where this is permissible is that of
tail-recursive functions of the form
f x1 x2 ... = cond c b (f y1 y2 ...)
where none of the expressions c
, b
, y1
, y2
, ... depend on f
. Where
applicable, such functions will be synthesized as GLSL loops. For example,
the factorial function can be computed within a vertex shader as follows:
fact = glFunc1 $ \n -> fact' n 1 where fact' :: GLExpr VertexDomain Int -> GLExpr VertexDomain Int -> GLExpr VertexDomain Int fact' = glFunc2 $ \n a -> cond (n .== 0) a (fact' (n - 1) (a * n)) x :: GLExpr VertexDomain Int x = fact 5
glFunc1 :: (GLType t, GLType t1) => (GLExpr d t1 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t Source #
glFunc2 :: (GLType t, GLType t1, GLType t2) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t Source #
glFunc3 :: (GLType t, GLType t1, GLType t2, GLType t3) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t Source #
glFunc4 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t Source #
glFunc5 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t Source #
glFunc6 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5, GLType t6) => (GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t6 -> GLExpr d t) -> GLExpr d t1 -> GLExpr d t2 -> GLExpr d t3 -> GLExpr d t4 -> GLExpr d t5 -> GLExpr d t6 -> GLExpr d t Source #
Lifts from raw types
If the need arises to use an n-ary native function f
that is not defined
over GLExpr
's (for instance, to dynamically update array contents using
functions defined on lists), such a function can be lifted to the
HostDomain
using glLiftn
. glLiftn f
will then be defined over
HostExpr
s that agree with respective argument types of f
. For example,
the two expressions below compute the same array:
a1 :: GLExpr HostDomain [Float] a1 = (glLift2 $ \x y -> [x, y, x + y]) time time a2 :: GLExpr HostDomain [Float] a2 = array [time, 2 * time, 3 * time]
glLift1 :: (GLType t, GLType t1) => (t1 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t Source #
glLift2 :: (GLType t, GLType t1, GLType t2) => (t1 -> t2 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t Source #
glLift3 :: (GLType t, GLType t1, GLType t2, GLType t3) => (t1 -> t2 -> t3 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t Source #
glLift4 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4) => (t1 -> t2 -> t3 -> t4 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t Source #
glLift5 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5) => (t1 -> t2 -> t3 -> t4 -> t5 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t5 -> GLExpr 'HostDomain t Source #
glLift6 :: (GLType t, GLType t1, GLType t2, GLType t3, GLType t4, GLType t5, GLType t6) => (t1 -> t2 -> t3 -> t4 -> t5 -> t6 -> t) -> GLExpr 'HostDomain t1 -> GLExpr 'HostDomain t2 -> GLExpr 'HostDomain t3 -> GLExpr 'HostDomain t4 -> GLExpr 'HostDomain t5 -> GLExpr 'HostDomain t6 -> GLExpr 'HostDomain t Source #
Built-in I/O variables
mouseRight :: HostExpr Bool Source #
True if and only if the right mouse button is pressed
mouseWheel :: HostExpr Float Source #
A pulse signal, equal to 1 at the moment the mouse wheel scrolls up, -1 when the mouse wheel scrolls down, and afterwards exponentially decaying to its otherwise default value of 0
mouseX :: HostExpr Float Source #
The horizontal position of the mouse, not necessarily within the window bounds
mouseY :: HostExpr Float Source #
The vertical position of the mouse, not necessarily within the window bounds
Drawables
class Drawable a where Source #
Anything that can be drawn using a given Backend
Instances
Drawable GLObj Source # | A |
Drawable [GLObj] Source # | A set of |
A drawable object specified by a set of variables of type GLExpr
and
the PrimitiveMode
according to which output vertices of the variable
position
, indexed by indices
, should be interpreted.
When using the convenience functions points
,
triangles
, etc., to define a GLObj
with the corresponding
PrimitiveMode
, at the very minimum the fields position
and color
must
be set before drawing the GLObj
.
GLObj | |
|
Instances
Drawable GLObj Source # | A |
Drawable [GLObj] Source # | A set of |
type PrimitiveMode = PrimitiveMode Source #
See Graphics.Rendering.OpenGL.GL.PrimitiveMode
for a description of each PrimitiveMode
triangleStrip :: GLObj Source #
An incompletely specified object with PrimitiveMode
equal to TriangleStrip
triangleFan :: GLObj Source #
An incompletely specified object with PrimitiveMode
equal to TriangleFan
Backends
A backend that can interpret (draw) a Drawable
.
Unless overridden the following OpenGL options are set by default in all backends:
- Clear color equal to black
- Depth testing enabled
- Blending enabled with blend equation equal to GL_FUNC_ADD
- Source blending factor equal to GL_SRC_ALPHA
- Destination blending factor equal to GL_ONE_MINUS_SRC_ALPHA
data GlutOptions Source #
Options specific to a GLUT window
GlutOptions | |
|
data GlutRunMode Source #
GlutRunMode
specifies how to run the resulting application
GlutNormal | Display the output in a window |
GlutCaptureLatest String | Display the output in a window, saving the latest frame in the specified file location |
GlutCaptureFrames String | Display the output in a window, saving all frames in the specified directory |
GlutCaptureAndExit String | Display the output in a window for a brief period time, saving the latest frame in the specified file location |
drawGlutCustom :: Drawable a => GlutOptions -> a -> IO () Source #
Draw in a GLUT backend using specified options
defaultGlutOptions :: GlutOptions Source #
Default options for a GLUT backend
winSize = (768, 768)
clearCol = (0, 0, 0, 0)
runMode = GlutNormal