Skip to content

Commit cf5a358

Browse files
fix: Got 100% unit tests in chrome, ff, safari, and node.
1 parent a586c0d commit cf5a358

32 files changed

+2174
-1921
lines changed

bin/gpu-browser-core.js

+597-577
Large diffs are not rendered by default.

bin/gpu-browser.js

+597-577
Large diffs are not rendered by default.

examples/random.html

+32-10
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
<html>
2+
<title>GPU.js Random Examples</title>
23
<body>
34
<h2>CPU Random</h2>
45
<canvas id="cpu-random-output"></canvas>
5-
<h2>GPU Random</h2>
6-
<canvas id="gpu-random-output"></canvas>
6+
<h2>WebGL1 Random</h2>
7+
<canvas id="web-gl-random-output"></canvas>
8+
<h2>WebGL2 Random</h2>
9+
<canvas id="web-gl2-random-output"></canvas>
710
</body>
811
<script src="../bin/gpu-browser.js"></script>
912
<script>
13+
const cpu = new GPU({
14+
mode: 'cpu',
15+
canvas: document.getElementById('cpu-random-output')
16+
});
17+
const webGL = new GPU({
18+
mode: 'webgl',
19+
canvas: document.getElementById('web-gl-random-output')
20+
});
21+
const webGL2 = new GPU({
22+
mode: 'webgl2',
23+
canvas: document.getElementById('web-gl2-random-output')
24+
});
25+
1026
function drawRandomFunction() {
11-
this.color(Math.random(), Math.random(), Math.random(), 1);
27+
this.color(Math.random(), Math.random(), Math.random());
1228
}
1329

14-
const cpu = new GPU({ mode: 'cpu', canvas: document.getElementById('cpu-random-output') });
15-
const gpu = new GPU({ mode: 'gpu', canvas: document.getElementById('gpu-random-output') });
16-
1730
const cpuDrawRandom = cpu.createKernel(drawRandomFunction)
1831
.setGraphical(true)
1932
.setOutput([100, 100]);
2033

21-
const gpuDrawRandom = gpu.createKernel(drawRandomFunction)
34+
const webGLDrawRandom = webGL.createKernel(drawRandomFunction)
35+
.setGraphical(true)
36+
.setOutput([100, 100]);
37+
38+
const webGL2DrawRandom = webGL2.createKernel(drawRandomFunction)
2239
.setGraphical(true)
2340
.setOutput([100, 100]);
2441

25-
setInterval(() => {
42+
function draw() {
2643
cpuDrawRandom();
27-
gpuDrawRandom();
28-
}, 10);
44+
webGLDrawRandom();
45+
webGL2DrawRandom();
46+
47+
requestAnimationFrame(draw);
48+
}
49+
50+
requestAnimationFrame(draw);
2951
</script>
3052
</html>

0 commit comments

Comments
 (0)