diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-16 07:15:29 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-16 07:29:03 +0100 |
commit | 6700a057f30e8ca6c8aa2dde71d03516fd7ae6cd (patch) | |
tree | 5cafa9969ae9eb0884abd4b1ece21916d1680b91 /lc | |
parent | 2c1c5a8ae057c4e3a93ccf2a6f796af87188c0d1 (diff) |
generate functions in shaders
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc index d4226f25..5eead277 100644 --- a/lc/Builtins.lc +++ b/lc/Builtins.lc | |||
@@ -53,14 +53,10 @@ type family MatVecScalarElem a where | |||
53 | 53 | ||
54 | data Swizz = Sx | Sy | Sz | Sw | 54 | data Swizz = Sx | Sy | Sz | Sw |
55 | 55 | ||
56 | -- todo: use pattern matching | 56 | mapVec :: (a -> b) -> VecS a n -> VecS b n |
57 | mapVec :: forall a b m . (a -> b) -> Vec m a -> Vec m b | 57 | mapVec f (V2 x y) = V2 (f x) (f y) |
58 | mapVec @a @b @m f v = 'VecSCase (\m _ -> 'Vec m b) | 58 | mapVec f (V3 x y z) = V3 (f x) (f y) (f z) |
59 | (\x y -> V2 (f x) (f y)) | 59 | mapVec f (V4 x y z w) = V4 (f x) (f y) (f z) (f w) |
60 | (\x y z -> V3 (f x) (f y) (f z)) | ||
61 | (\x y z w -> V4 (f x) (f y) (f z) (f w)) | ||
62 | @m | ||
63 | v | ||
64 | 60 | ||
65 | -- todo: make it more type safe | 61 | -- todo: make it more type safe |
66 | swizzscalar :: forall n . Vec n a -> Swizz -> a | 62 | swizzscalar :: forall n . Vec n a -> Swizz -> a |