Skip to content

Instantly share code, notes, and snippets.

@taesiri
Last active October 15, 2017 13:34
Show Gist options
  • Save taesiri/9ece9ca01bc58bfa661306cc6f325f89 to your computer and use it in GitHub Desktop.
Save taesiri/9ece9ca01bc58bfa661306cc6f325f89 to your computer and use it in GitHub Desktop.
gpu.js Hello World!

gpu.js Hello World

Hello World sample in gpu.js

Screenshot

<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>gpu.js demo</title>
<script src='gpu.js'></script>
</head>
<body>
</body>
<script>
const gpu = new GPU();
const render = gpu.createKernel(function() {
var r = (this.thread.x)/800.0;
var g = (400-this.thread.y)/400.0;
var b = 0.2;
this.color(r,g,b,1);
})
.setOutput([800, 400])
.setGraphical(true);
render();
const canvas = render.getCanvas();
document.getElementsByTagName('body')[0].appendChild(canvas);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment