console
console.log("2222")
function setupGLEnv(canvasID) {
canvas = document.getElementById(canvasID);
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (!gl) {
alert('天呐!您的浏览器竟然不支持WebGL,快去更新浏览器吧。');
}
}
function renderLoop() {
now = (new Date()).getTime();
deltaTime = now - lastRenderTime;
lastRenderTime = now;
elapsedTime += deltaTime;
render(deltaTime, elapsedTime);
collectedFrameDuration += deltaTime;
collectedFrameCount++;
if (collectedFrameCount >= 10) {
fps = parseInt(1000.0 * collectedFrameCount / collectedFrameDuration);
if (isNaN(fps) == false || fps < 1000) {
glInfoNode.textContent = "FPS: " + fps;
}
collectedFrameCount = 0;
collectedFrameDuration = 0;
}
requestAnimationFrame(renderLoop);
}
function render(deltaTime, elapesdTime) {
gl.clearColor(1.0, .0, .0, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT);
}
window.onload = function() {
setupGLEnv('glCanvas');
glInfoNode = document.getElementById("glInfo");
resize(canvas.parentElement.clientWidth, canvas.parentElement.clientHeight - 1);
renderLoop();
}
<div style="width: 100%; height: 300px; position:relative; background:rgba(0,0,0,0);">
<canvas id="glCanvas" width="400" height="300">
Your browser doesn't appear to support the
<code><canvas></code> element.
</canvas>
<div id="glInfo" style=""></div>
</div>