Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  var gl;
  2.  
  3. function start() {
  4.     var canvas = document.getElementById("holochrist");  
  5.  
  6.     initWebGL(canvas);      // Initialize the GL context  
  7.    
  8.     // Only continue if WebGL is available and working  
  9.    
  10.     if (gl) {
  11.         gl.clearColor(0.0, 0.0, 0.0, 1.0);
  12.         gl.enable(gl.DEPTH_TEST);
  13.         gl.depthFunc(gl.LEQUAL);
  14.         gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);
  15.        
  16.         /*******************************************************|
  17.         |    1. Set clear color to black, fully opaque          |
  18.         |    2. Enable depth testing                            |
  19.         |    3. Near things obscure far things                  |
  20.         |    4. Clear the color as well as the depth buffer.    |
  21.         ********************************************************/
  22.     }    
  23. }
  24.  
  25. function initWebGL(canvas) {
  26.     gl = null;  //Initialize the global var gl to null.
  27.    
  28.     try {
  29.         //Try to grab the standard context. If it fails, use experimental.
  30.         gl = canvas.getContext("webgl") || canvas.getContext("experimantal-webgl");
  31.         gl.viewport(0, 0, canvas.width, canvas.height();
  32.     }
  33.     catch(e) {}
  34.    
  35.     if (!gl) {  //If we can't get GL context, give up.
  36.         alert("Unable to initalize WebGL.
  37.                Your browser propably doesn't support it");  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement