on master help sign in
docs that are compatible with elm-get
909c426John P Mayer Jr
libraries/Graphics/WebGL.elm+12−3
@@ -3,7 +3,7 @@ module Graphics.WebGL (mapTriangle, zipTriangle, loadTex, model, webgl) where
3{-| The WebGL API is for high performance drawing.
3{-| The WebGL API is for high performance drawing.
4
4
5# Triangle Convenience Functions
5# Triangle Convenience Functions
6−@docs Triangle, mapTriangle, zipTriangle
6+@docs mapTriangle, zipTriangle
7
7
8# Shaders
8# Shaders
9Shaders are created using glsl blocks.
9Shaders are created using glsl blocks.
@@ -17,10 +17,10 @@ void main () {
17 gl_Position = vec4(pos,1.0);
17 gl_Position = vec4(pos,1.0);
18}
18}
19
19
20−|]
20+\]
21
21
22# WebGL Element
22# WebGL Element
23−@docs webgl
23+@docs loadTex, model, webgl
24
24
25-}
25-}
26
26
@@ -32,25 +32,34 @@ import Signal (Signal)
32unsafeCoerceGLSL : String -> Shader attr unif vary
32unsafeCoerceGLSL : String -> Shader attr unif vary
33unsafeCoerceGLSL = Native.Graphics.WebGL.unsafeCoerceGLSL
33unsafeCoerceGLSL = Native.Graphics.WebGL.unsafeCoerceGLSL
34
34
35+{-| An alias for a 3-tuple -}
35type Triangle a = (a,a,a)
36type Triangle a = (a,a,a)
36
37
38+{-| Apply a function to each vertex -}
37mapTriangle : (a -> b) -> Triangle a -> Triangle b
39mapTriangle : (a -> b) -> Triangle a -> Triangle b
38mapTriangle f (x,y,z) = (f x, f y, f z)
40mapTriangle f (x,y,z) = (f x, f y, f z)
39
41
42+{-| Apply an arity-2 function element-wise on 2 triangles -}
40zipTriangle : (a -> b -> c) -> Triangle a -> Triangle b -> Triangle c
43zipTriangle : (a -> b -> c) -> Triangle a -> Triangle b -> Triangle c
41zipTriangle f (x,y,z) (x',y',z') = (f x x', f y y', f z z')
44zipTriangle f (x,y,z) (x',y',z') = (f x x', f y y', f z z')
42
45
46+{-| Opaque Shader Type -}
43data Shader attr unif vary = Shader
47data Shader attr unif vary = Shader
44
48
49+{-| Opaque Texture Type -}
45data Texture = Texture
50data Texture = Texture
46
51
52+{-| Load an image url as a texture -}
47loadTex : String -> Signal (Response Texture)
53loadTex : String -> Signal (Response Texture)
48loadTex = Native.Graphics.WebGL.loadTex
54loadTex = Native.Graphics.WebGL.loadTex
49
55
56+{-| Opaque Model Type -}
50data Model = Model
57data Model = Model
51
58
59+{-| A model is a collection of a fragment shader, a vertex shader, attribute data, and uniform data. -}
52model : Shader attr unif vary -> Shader {} unif vary -> [Triangle attr] -> unif -> Model
60model : Shader attr unif vary -> Shader {} unif vary -> [Triangle attr] -> unif -> Model
53model = Native.Graphics.WebGL.model
61model = Native.Graphics.WebGL.model
54
62
63+{-| Render a WebGL scene with the given dimensions and models -}
55webgl : (Int,Int) -> [Model] -> Element
64webgl : (Int,Int) -> [Model] -> Element
56webgl = Native.Graphics.WebGL.webgl
65webgl = Native.Graphics.WebGL.webgl