on bd135f3 help sign in
53 lines 1.2 kB history raw
1module Graphics.WebGL (mapTriangle, zipTriangle, loadTex, model, webgl) where
3{-| The WebGL API is for high performance drawing.
5# Triangle Convenience Functions
6@docs Triangle, mapTriangle, zipTriangle
8# Shaders
9Shaders are created using glsl blocks.
11vertex : Shader { a | pos : V3 } {} {}
12vertex = [glsl|
14attribute vec3 pos;
16void main () {
17 gl_Position = vec4(pos,1.0);
20|]
22# WebGL Element
23@docs webgl
25-}
27import Graphics.Element (Element)
28import Http (Response)
29import Native.Graphics.WebGL
30import Signal (Signal)
32type Triangle a = (a,a,a)
34mapTriangle : (a -> b) -> Triangle a -> Triangle b
35mapTriangle f (x,y,z) = (f x, f y, f z)
37zipTriangle : (a -> b -> c) -> Triangle a -> Triangle b -> Triangle c
38zipTriangle f (x,y,z) (x',y',z') = (f x x', f y y', f z z')
40data Shader attr unif vary = Shader
42data Texture = Texture
44loadTex : String -> Signal (Response Texture)
45loadTex = Native.Graphics.WebGL.loadTex
47data Model = Model
49model : Shader attr unif vary -> Shader {} unif vary -> [Triangle attr] -> unif -> Model
50model = Native.Graphics.WebGL.model
52webgl : (Int,Int) -> [Model] -> Element
53webgl = Native.Graphics.WebGL.webgl