{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
module Hylogen.Globals where
import Hylogen.Types
import Hylogen.Expr
len :: forall n. (Veccable n) => Vec n -> Vec1
len = op1pre "length"
distance :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n
distance = op2pre'' "distance"
cross :: Vec3 -> Vec3 -> Vec3
cross = op2pre'' "cross"
normalize :: forall n. (Veccable n) => Vec n -> Vec n
normalize = op1pre'' "normalize"
faceForward :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n -> Vec n
faceForward = op3pre'' "faceforward"
reflect :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n
reflect = op2pre'' "reflect"
refract :: forall n. (Veccable n) => Vec n -> Vec n -> Vec1 -> Vec n
refract = op3pre "refract"
inverseSqrt :: forall n. (Veccable n) => Vec n -> Vec n
inverseSqrt = op1pre'' "inversesqrt"
fract :: forall n. (Veccable n) => Vec n -> Vec n
fract = op1pre'' "fract"
mod_ :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n
mod_ = op2pre'' "mod"
floor_:: forall n. (Veccable n) => Vec n -> Vec n
floor_ = op1pre'' "floor"
ceil_ :: forall n. (Veccable n) => Vec n -> Vec n
ceil_ = op1pre'' "ceil"
min_ :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n
min_ = op2pre'' "min"
max_ :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n
max_ = op2pre'' "max"
clamp :: forall n. (Veccable n) => Vec n -> Vec n -> Vec n -> Vec n
clamp mn mx x = op3pre'' "clamp" x mn mx
mix :: (Veccable n) => Vec1 -> Vec n -> Vec n -> Vec n
mix p x y = op3pre "mix" x y p
true :: Booly
true = uniform "true"
false :: Booly
false = uniform "false"
bcomp :: (Veccable v) => String -> Vec v -> Vec v -> Booly
bcomp str x y = product $ zipWith (op2' str) (toList x) (toList y)
eq :: (Veccable v) => Vec v -> Vec v -> Booly
eq = bcomp "=="
neq :: (Veccable v) => Vec v -> Vec v -> Booly
neq = bcomp "!="
lt :: (Veccable v) => Vec v -> Vec v -> Booly
lt = bcomp "<"
gt :: (Veccable v) => Vec v -> Vec v -> Booly
gt = bcomp ">"
leq :: (Veccable v) => Vec v -> Vec v -> Booly
leq = bcomp "<="
geq :: (Veccable v) => Vec v -> Vec v -> Booly
geq = bcomp ">="
texture2D :: Texture -> Vec2 -> Vec4
texture2D = op2pre "texture2D"
sel :: forall a
. (ToGLSLType a)
=> Booly -> Expr a -> Expr a -> Expr a
sel a b c = Expr t (Tree (Select, toGLSLType t, "") [toMono a, toMono b, toMono c])
where t = tag :: a