Skip to content

Commit

Permalink
adjust vector version and fix exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
csabahruska committed Feb 5, 2016
1 parent a902504 commit 9479838
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler-service/compiler-service.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ executable compiler-service
lambdacube-compiler == 0.4.*,
pretty-show == 1.6.*,
containers,
vector,
vector >= 0.11 && <0.12,
parsec,
aeson-pretty,
process,
Expand Down
2 changes: 1 addition & 1 deletion exercises/Cube.lc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
makeFrame (projmat :: Mat 4 4 Float)
(vertexstream :: Stream (Primitive Triangle (Vec 4 Float)))
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay` fragments
Expand Down
2 changes: 1 addition & 1 deletion exercises/LambdaCube.lc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ len2 v = v%x*v%x + v%y*v%y + v%z*v%z

makeFrame (time :: Float)
(projmat :: Mat 4 4 Float)
(vertexstream :: Stream (Primitive Triangle (Vec 4 Float)))
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay`
Expand Down
2 changes: 1 addition & 1 deletion exercises/LambdaCube2.lc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ len2 v = v%x*v%x + v%y*v%y + v%z*v%z

makeFrame (time :: Float)
(projmat :: Mat 4 4 Float)
(vertexstream :: Stream (Primitive Triangle (Vec 4 Float)))
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay`
Expand Down
2 changes: 1 addition & 1 deletion exercises/MagicCube.lc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ f x = (x + sin x + sin (1.1 * x)) `mod` 4 * 2

makeFrame (time :: Float)
(projmat :: Mat 4 4 Float)
(vertexstream :: Stream (Primitive Triangle (Vec 4 Float)))
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay`
Expand Down
2 changes: 1 addition & 1 deletion exercises/Stripes.lc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

makeFrame (time :: Float)
(vertexstream :: Stream (Primitive Triangle (Vec 4 Float)))
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= foldl' overlay (imageFrame (emptyDepthImage 1, emptyColorImage navy))
$ map (f . (/10)) [ 1 .. 10 ]
Expand Down
31 changes: 31 additions & 0 deletions exercises/Tetrahedron.lc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tetrahedron =
[ V3 0 0 0, V3 1 0 0, V3 0 1 0
, V3 1 0 0, V3 0 1 0, V3 0 0 1
, V3 0 1 0, V3 0 0 1, V3 0 0 0
, V3 0 0 1, V3 0 0 0, V3 0 0 1
]

f x = (x + sin x + sin (1.1 * x)) `mod` 4 * 2

makeFrame (time :: Float)
(projmat :: Mat 4 4 Float)
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float))

= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay` accumulablefragments
where
accumulablefragments
= vertexstream
& mapPrimitives (\x -> (scale 0.5 (projmat *. x), x))
& rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) Smooth
& filterFragments (\x -> True)
& mapFragments (\x -> (rotMatrixZ time *. rotMatrixY time *. x) *! f time)
& accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))

main = renderFrame $
makeFrame (Uniform "Time")
(Uniform "MVP")
tetrahedronStream

tetrahedronStream = fetchArrays Triangle $ map (\v -> V4 v%x v%y v%z 1) tetrahedron

0 comments on commit 9479838

Please sign in to comment.