| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 <!DOCTYPE html> | |
| 7 <html> | |
| 8 <head> | |
| 9 <meta charset="utf-8"> | |
| 10 <title>WebGL More than 65536 points.</title> | |
| 11 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
| 12 <script src="../resources/js-test-pre.js"></script> | |
| 13 <script src="resources/webgl-test.js"> </script> | |
| 14 <script src="resources/webgl-test-utils.js"> </script> | |
| 15 </head> | |
| 16 <body> | |
| 17 <canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"><
/canvas> | |
| 18 <div id="description"></div> | |
| 19 <div id="console"></div> | |
| 20 <script id="vs" type="text/something-not-javascript"> | |
| 21 attribute vec4 vPosition; | |
| 22 attribute vec4 vColor; | |
| 23 varying vec4 color; | |
| 24 void main() { | |
| 25 gl_Position = vPosition; | |
| 26 color = vColor; | |
| 27 } | |
| 28 </script> | |
| 29 <script id="fs" type="text/something-not-javascript"> | |
| 30 precision mediump float; | |
| 31 varying vec4 color; | |
| 32 void main() { | |
| 33 gl_FragColor = color; | |
| 34 } | |
| 35 </script> | |
| 36 <script> | |
| 37 var wtu = WebGLTestUtils; | |
| 38 var gl = initWebGL("example", "vs", "fs", ["vPosition", "vColor"], [0, 0, 0, 1],
1); | |
| 39 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after initWebGL"); | |
| 40 var bufferObjects = wtu.setupUnitQuad(gl, 0, 1); | |
| 41 gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0]); | |
| 42 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ | |
| 43 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0, | |
| 44 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW); | |
| 45 gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[1]); | |
| 46 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([ | |
| 47 255, 0, 0, 255, | |
| 48 255, 0, 0, 255, | |
| 49 255, 0, 0, 255, | |
| 50 255, 0, 0, 255, | |
| 51 0, 255, 0, 255, | |
| 52 0, 255, 0, 255, | |
| 53 0, 255, 0, 255, | |
| 54 0, 255, 0, 255]), gl.STATIC_DRAW); | |
| 55 gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0); | |
| 56 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after program setup"); | |
| 57 gl.enable(gl.BLEND); | |
| 58 gl.disable(gl.DEPTH_TEST); | |
| 59 | |
| 60 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after creating texture"); | |
| 61 var numQuads = Math.floor(65536 / 6) + 2; | |
| 62 debug("numQuads: " + numQuads); | |
| 63 debug("numPoints: " + numQuads * 6); | |
| 64 var indexBuf = new ArrayBuffer(numQuads * 6); | |
| 65 var indices = new Uint8Array(indexBuf); | |
| 66 for (var ii = 0; ii < numQuads; ++ii) { | |
| 67 var offset = ii * 6; | |
| 68 var quad = (ii == (numQuads - 1)) ? 4 : 0; | |
| 69 indices[offset + 0] = quad + 0; | |
| 70 indices[offset + 1] = quad + 1; | |
| 71 indices[offset + 2] = quad + 2; | |
| 72 indices[offset + 3] = quad + 2; | |
| 73 indices[offset + 4] = quad + 1; | |
| 74 indices[offset + 5] = quad + 3; | |
| 75 } | |
| 76 var indexBuffer = gl.createBuffer(); | |
| 77 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); | |
| 78 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); | |
| 79 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices"); | |
| 80 gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0); | |
| 81 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing"); | |
| 82 wtu.checkCanvas(gl, [0, 255, 0, 255], "Should be green."); | |
| 83 | |
| 84 successfullyParsed = true; | |
| 85 </script> | |
| 86 | |
| 87 <script src="../resources/js-test-post.js"></script> | |
| 88 | |
| 89 </body> | |
| 90 </html> | |
| 91 | |
| 92 | |
| OLD | NEW |