aboutsummaryrefslogtreecommitdiff
path: root/demos/raytrace.html
blob: 0996e2681ee082bfffb5314d28a171b7955862ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head>
  <title>
    Emscripten: Raytracing
  </title>
  <script src="raytrace.js"></script>
  <script>
    // print function which the cubescript engine will call
    function print(text) {
      document.getElementById('output').innerHTML = text;
      printed = true;
    }

    // Do everything - initialize SDL, set up canvas, render
    function render() {
      _SDL_Init(32);
      var canvas = document.getElementById('canvas');
      HEAP[_screen] = _SDL_SetVideoMode(canvas.width, canvas.height, 32, 0, canvas);
      var y = canvas.height-1;
      function drawLine() {
        __ZL10trace_lineiii(canvas.width, canvas.width, y);
        print("Generating: " + (canvas.height-y) + "/" + canvas.height);
        y--;
        if (y >= 0) {
          setTimeout(arguments.callee, 1);
        }
      }
      drawLine();
    }
  </script>
</head>
<body onload='render()'>
  <canvas id='canvas' width=128 height=128></canvas>
  <hr>
  <div id="output" style="font-family: Courier New,Courier,monospace;">Generating scene data, please wait...</div>
  <hr>
  Simple raytracing demo. The <a href="http://ompf.org/ray/sphereflake/">original C++ source</a> was
  automatically converted to JavaScript using <a href="http://emscripten.org">Emscripten</a>.
</body>
</html>