Created
July 10, 2015 07:25
-
-
Save jhegedus42/a523aff2a411c71aecd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear = FrameBuffer $ (DepthImage @1 1000, ColorImage @1 navy) -- ... | |
triangleRasterCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex | |
colorFragmentCtx = AccumulationContext (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | |
rasterizeWith = Rasterize | |
triangles = triangleRasterCtx | |
cubeVertexStream = Fetch "stream4" Triangles (Attribute "position4" :: Vec 4 Float) | |
mapFragments s fs = Accumulate colorFragmentCtx PassAll (\a -> FragmentOutRastDepth $ fs a) s clear | |
transform s f = Transform (\v -> VertexOut (f v) 1 () (Smooth v)) s | |
rotate' v = (Uniform "MVP" :: Mat 4 4 Float) *. v | |
pulse = (abs ((sin time)/3)) | |
main = cubeVertexStream -- cube vertices | |
`transform` (scale ( pulse ). rotate') -- scale them | |
& rasterizeWith triangles -- rasterize | |
`mapFragments` id | |
& ScreenOut -- draw into screen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment