Skip to content

Instantly share code, notes, and snippets.

@EdPoole
Last active December 30, 2015 04:59
Show Gist options
  • Save EdPoole/7779812 to your computer and use it in GitHub Desktop.
Save EdPoole/7779812 to your computer and use it in GitHub Desktop.
Web Graphics Vision
function startup() {
canvas = document.getElementById("canvas");
canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
canvas.addEventListener('webglcontextlost', handleContextLost, false);
canvas.addEventListener('webglcontextrestored', handleContextRestored, false);
window.addEventListener('mousedown', function() {
canvas.loseContext();
});
gl = createGLContext(canvas);
console.log(gl);
setupShaders();
setupBuffers();
setupTextures();
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.enable(gl.DEPTH_TEST);
draw();
}
function startup() {
canvas = document.getElementById("canvas");
canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
canvas.addEventListener('webglcontextlost', handleContextLost, false);
canvas.addEventListener('webglcontextrestored', handleContextRestored, false);
document.addEventListener('keydown', handleKeyDown, false);
document.addEventListener('keyup', handleKeyUp, false);
canvas.addEventListener('mousemove', mymousemove, false);
canvas.addEventListener('mousedown', mymousedown, false);
canvas.addEventListener('mouseup', mymouseup, false);
canvas.addEventListener('mousewheel', wheelHandler, false);
canvas.addEventListener('DOMMouseScroll', wheelHandler, false);
gl = createGLContext(canvas);
console.log(gl);
init();
pwgl.fpsCounter = document.getElementById("fps");
// Draw the complete scene
draw();
}
@EdPoole
Copy link
Author

EdPoole commented Dec 3, 2013

On both, I'm console logging what gl is.

Tutorial 08 returns an object, yet tutorial 09 returns null.

Both call canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas); yet 09 returns null from that. And it's the same WebGLDebugUtils file.

@40thieves
Copy link

sidenote, but i've found console.logging lags my machine like crazy (if you're logging in the draw loop that is)

@40thieves
Copy link

Yeah, startup looks good. The problem I had was that it was drawing fine, but the box that's supposed to be on top of the table was way off (like 1000 off), so couldn't see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment