Changes between Version 1 and Version 2 of webgl
- Timestamp:
- Oct 4, 2013, 4:13:38 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
webgl
v1 v2 5 5 #!html 6 6 <b>hi</b> 7 <script type= ”text/javascript”>7 <script type="text/javascript"> 8 8 var gl; 9 9 var canvas; … … 12 12 13 13 function createGLContext(canvas) { 14 var names = [ “webgl”, “experimental-webgl”];14 var names = ["webgl", "experimental-webgl"]; 15 15 var context = null; 16 16 for (var i=0; i < names.length; i++) { … … 26 26 context.viewportHeight = canvas.height; 27 27 } else { 28 alert( “Failed to create WebGL context!”);28 alert("Failed to create WebGL context!"); 29 29 } 30 30 return context; … … 46 46 function setupShaders() { 47 47 var vertexShaderSource = 48 “attribute vec3 aVertexPosition; \n”+49 “void main() { \n”+50 “ gl_Position = vec4(aVertexPosition, 1.0); \n”+51 “} \n”;48 "attribute vec3 aVertexPosition; \n" + 49 "void main() { \n" + 50 " gl_Position = vec4(aVertexPosition, 1.0); \n" + 51 "} \n"; 52 52 53 53 var fragmentShaderSource = 54 “precision mediump float; \n”+55 “void main() { \n”+56 “ gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); \n”+57 “} \n”;54 "precision mediump float; \n"+ 55 "void main() { \n"+ 56 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); \n"+ 57 "} \n"; 58 58 59 59 var vertexShader = loadShader(gl.VERTEX_SHADER, vertexShaderSource); … … 72 72 73 73 shaderProgram.vertexPositionAttribute = 74 gl.getAttribLocation(shaderProgram, “aVertexPosition”);74 gl.getAttribLocation(shaderProgram, "aVertexPosition"); 75 75 } 76 76 … … 102 102 103 103 function startup() { 104 canvas = document.getElementById( “myGLCanvas”);104 canvas = document.getElementById("myGLCanvas"); 105 105 gl = createGLContext(canvas); 106 106 setupShaders(); … … 113 113 </head> 114 114 115 <canvas id= ”myGLCanvas” width=”500” height=”500”></canvas>115 <canvas id="myGLCanvas" width="500" height="500"></canvas> 116 116 <form><input type="button" value="Draw" onclick="startup()"/></form> 117 117