on master help sign in
got the plumbing working correctly
commitf8c7aea297254ed65529e99a14c08527c4c5d5d3 authorJohn P Mayer Jr <john.p.mayer.jr@gmail.com> dateMon 11 Nov 2013, 16:05 (13 years ago) parenteef3a4b
2 files changed+47−27
libraries/Graphics/WebGL.elm+21 libraries/Native/Graphics/WebGL.js+26−27
libraries/Graphics/WebGL.elmnew file+21
@@ -0,0 +1,21 @@
1+module Graphics.WebGL where
2+
3+{-| WebGL
4+
5+-}
6+
7+import Basics (Float)
8+import Graphics.Element (Element)
9+import Native.Graphics.WebGL
10+
11+type GLPoint = { x: Float, y: Float, z: Float }
12+type GLColor = { r: Int, g: Int, b: Int, a: Int }
13+type GLTriangle = { a: GLPoint, b: GLPoint, c: GLPoint }
14+type Model = [(GLColor,GLTriangle)]
15+
16+data Transform = NoTransform
17+
18+data Scene = Node Transform [Scene] | Leaf Model
19+
20+glContext : Int -> Int -> Scene -> Element
21+glContext = Native.Graphics.WebGL.glContext
libraries/Native/Graphics/WebGL.js+26−27
@@ -15,38 +15,37 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
1515 //var Utils = Elm.Native.Utils.make(elm);
1616 //var Tuple2 = Utils.Tuple2;
1717
18+ function drawGL(ctx,model) {
19+ var scene = model.scene;
20+ console.log(scene);
21+ }
22+
23+ function render(model) {
24+ var canvas = newNode('canvas');
25+ gl = canvas.getContext("webgl");
26+ drawGL(gl,model);
27+ return canvas;
28+ }
29+
30+ function update(canvasNode, _oldModel, newModel) {
31+ gl = canvasNode.getContext("webgl");
32+ drawGL(gl,newModel)
33+ }
34+
1835 function glContext(w,h,scene) {
1936
20− function drawGL(ctx,model) {
21− throw "Not implemented"
22− }
23−
24− function render(model) {
25− var canvas = newNode('canvas');
26− gl = canvas.getContext("webgl");
27− drawGL(gl,model);
28− return canvas;
29− }
30−
31− function update(canvasNode, _oldModel, newModel) {
32− gl = canvasNode.getContext("webgl");
33− drawGL(gl,newModel)
34− }
35−
36− return function (scene) {
37− return A3(newElement, 100, 40, {
38− ctor: 'Custom',
39− type: 'WebGL',
40− render: render,
41− update: update,
42− model: scene,
43− });
44− }
37+ return A3(newElement, w, h, {
38+ ctor: 'Custom',
39+ type: 'WebGL',
40+ render: render,
41+ update: update,
42+ model: {scene:scene},
43+ });
4544
4645 }
4746
48− return elm.Native.Graphics.Input.values = {
49− glContext:glContext,
47+ return elm.Native.Graphics.WebGL.values = {
48+ glContext:F3(glContext),
5049 };
5150
5251};