DanAlucard

2.- contexto canvas WebGL

Dec 27th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.99 KB | None | 0 0
  1. <!-- define functions to be used later -->
  2. <script type="text/javascript">
  3.  
  4.     var GLwall;
  5.  
  6.     function GLdraw(){
  7.  
  8.     }
  9.  
  10.     function startGL(canvas) {
  11.         GLwall = null;
  12.         // Try to grab the standard context. If it fails, fallback to experimental.
  13.         GLwall = canvas.getContext("webgl", {alpha: false}) ||
  14.                  canvas.getContext("experimental-webgl", {alpha: false});
  15.                
  16.         if (!GLwall) {
  17.             alert("Could not initialise WebGL, sorry :-(");
  18.         }else{
  19.             canvas.width = 400;
  20.             canvas.height = 300;
  21.             GLwall.viewport(0, 0, canvas.width, canvas.height);
  22.             GLdraw();
  23.         }
  24.     }
  25. </script>
  26.  
  27.  
  28. <!-- define the canvas element -->
  29. <canvas id="webglTest1" width=400 height=300 ></canvas>
  30.  
  31. <!-- call the startGL function to start the canvas element -->
  32. <script type="text/javascript">
  33.     var startTest1 = document.getElementById('webglTest1');
  34.     startGL(startTest1);
  35. </script>
Add Comment
Please, Sign In to add comment