JSFiddle - React, Tailwind, and code Playground
HTML
<body onload="App.start">
<canvas id="myCanvas" width="640" height="480">Shiiiiit..</canvas>
</body>
JavaScript
var App = (function () {
'use strict';
var gl;
function initWebGL(canvas) {
gl = null;
try {
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
} catch (ignore) {
}
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
gl = null;
}
return gl;
}
App.start = function () {
var canvas = document.getElementById("myCanvas");
gl = initWebGL(canvas);
if (gl) {
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.LEQUAL);
gl.clear(gl.COLOR_BUFFER_BIT, gl.DEPTH_BUFFER_BIT);
}
};
});