Hello World sample in gpu.js
Last active
October 15, 2017 13:34
-
-
Save taesiri/9ece9ca01bc58bfa661306cc6f325f89 to your computer and use it in GitHub Desktop.
gpu.js Hello World!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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