1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/rendering/more-than-65536-indices.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.6 +Use of this source code is governed by a BSD-style license that can be 1.7 +found in the LICENSE file. 1.8 + --> 1.9 +<!DOCTYPE html> 1.10 +<html> 1.11 +<head> 1.12 +<meta charset="utf-8"> 1.13 +<title>WebGL More than 65536 indices.</title> 1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 +<script src="../../resources/js-test-pre.js"></script> 1.16 +<script src="../resources/webgl-test.js"> </script> 1.17 +<script src="../resources/webgl-test-utils.js"> </script> 1.18 +</head> 1.19 +<body> 1.20 +<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas> 1.21 +<div id="description"></div> 1.22 +<div id="console"></div> 1.23 +<script id="vs" type="text/something-not-javascript"> 1.24 +attribute vec4 vPosition; 1.25 +attribute vec4 vColor; 1.26 +varying vec4 color; 1.27 +void main() { 1.28 + gl_Position = vPosition; 1.29 + color = vColor; 1.30 +} 1.31 +</script> 1.32 +<script id="fs" type="text/something-not-javascript"> 1.33 +precision mediump float; 1.34 +varying vec4 color; 1.35 +void main() { 1.36 + gl_FragColor = color; 1.37 +} 1.38 +</script> 1.39 +<script> 1.40 +description("checks that rendering with more than 65536 indices works."); 1.41 +var wtu = WebGLTestUtils; 1.42 +// The antialias:false context creation attribute is a concession to some older and buggier drivers. 1.43 +var gl = initWebGL("example", "vs", "fs", ["vPosition", "vColor"], [0, 0, 0, 1], 1, { antialias: false }); 1.44 +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after initWebGL"); 1.45 +var bufferObjects = wtu.setupUnitQuad(gl, 0, 1); 1.46 +gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0]); 1.47 +gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 1.48 + -1,1,0, 1,1,0, -1,-1,0, 1,-1,0, 1.49 + -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW); 1.50 +gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[1]); 1.51 +gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([ 1.52 + 255, 0, 0, 255, 1.53 + 255, 0, 0, 255, 1.54 + 255, 0, 0, 255, 1.55 + 255, 0, 0, 255, 1.56 + 0, 255, 0, 255, 1.57 + 0, 255, 0, 255, 1.58 + 0, 255, 0, 255, 1.59 + 0, 255, 0, 255]), gl.STATIC_DRAW); 1.60 +gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0); 1.61 +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after program setup"); 1.62 +gl.enable(gl.BLEND); 1.63 +gl.disable(gl.DEPTH_TEST); 1.64 + 1.65 +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after creating texture"); 1.66 +var numQuads = Math.floor(65536 / 6) + 2; 1.67 +debug("numQuads: " + numQuads); 1.68 +debug("numPoints: " + numQuads * 6); 1.69 +var indexBuf = new ArrayBuffer(numQuads * 6); 1.70 +var indices = new Uint8Array(indexBuf); 1.71 +for (var ii = 0; ii < numQuads; ++ii) { 1.72 + var offset = ii * 6; 1.73 + var quad = (ii == (numQuads - 1)) ? 4 : 0; 1.74 + indices[offset + 0] = quad + 0; 1.75 + indices[offset + 1] = quad + 1; 1.76 + indices[offset + 2] = quad + 2; 1.77 + indices[offset + 3] = quad + 2; 1.78 + indices[offset + 4] = quad + 1; 1.79 + indices[offset + 5] = quad + 3; 1.80 +} 1.81 +var indexBuffer = gl.createBuffer(); 1.82 +gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); 1.83 +gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); 1.84 +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices"); 1.85 +gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0); 1.86 +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing"); 1.87 +wtu.checkCanvas(gl, [0, 255, 0, 255], "Should be green."); 1.88 + 1.89 +successfullyParsed = true; 1.90 +</script> 1.91 + 1.92 +<script>finishTest();</script> 1.93 + 1.94 +</body> 1.95 +</html> 1.96 + 1.97 +