Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / gl-vertex-attrib-zero-issues.html
blob5ecf5fd6b85b847fd64b109cc371878fc290469e
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>WebGL Enable Vertex Attrib Zero Test</title>
5 <script src="../../../resources/js-test.js"></script>
6 <script src="resources/webgl-test.js"> </script>
7 <script src="resources/webgl-test-utils.js"> </script>
8 </head>
9 <body>
10 <canvas id="example" width="50" height="50">
11 </canvas>
12 <div id="description"></div>
13 <div id="console"></div>
14 <script id="vshader" type="x-shader/x-vertex">
15 attribute vec4 vPosition;
16 void main()
18 gl_Position = vPosition;
20 </script>
22 <script id="fshader" type="x-shader/x-fragment">
23 void main()
25 gl_FragColor = vec4(0.0,0.0,0.0,0.0);
27 </script>
29 <script>
30 description("Test some of the issues of the difference between attrib 0 on OpenGL vs WebGL");
31 debug("");
32 var wtu = WebGLTestUtils;
33 var canvas = document.getElementById("example");
34 var gl = wtu.create3DContext(canvas);
36 function setup(numVerts, attribIndex) {
37 var program = wtu.setupProgram(
38 gl,
39 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
40 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
41 ['vPosition'], [attribIndex]);
42 // draw with something on attrib zero with a small number of vertices
43 var vertexObject = gl.createBuffer();
44 g_program = program;
45 g_attribLocation = attribIndex;
46 shouldBe("g_attribLocation", "gl.getAttribLocation(g_program, 'vPosition')");
47 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
48 gl.bufferData(
49 gl.ARRAY_BUFFER, new Float32Array(numVerts * 3), gl.STATIC_DRAW);
50 gl.vertexAttribPointer(attribIndex, 3, gl.FLOAT, false, 0, 0);
51 var indices = new Uint16Array(numVerts);
52 for (var ii = 0; ii < numVerts; ++ii) {
53 indices[ii] = ii;
55 var indexBuffer = gl.createBuffer();
56 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
57 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
58 return program;
61 var p1 = setup(3, 0);
62 var p2 = setup(60000, 3);
64 for (var ii = 0; ii < 5; ++ii) {
65 gl.useProgram(p1);
66 gl.enableVertexAttribArray(0);
67 gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
68 glErrorShouldBe(
69 gl, gl.NO_ERROR,
70 "drawing using attrib 0 with 3 verts");
72 gl.useProgram(p2);
73 gl.enableVertexAttribArray(3);
74 gl.drawArrays(gl.LINES, 0, 60000);
75 glErrorShouldBe(
76 gl, gl.NO_ERROR,
77 "drawing using attrib 3 with 60000 verts");
80 wtu.checkCanvas(gl, [0, 0, 0, 0], "canvas should be 0, 0, 0, 0");
81 </script>
83 <script>
84 </script>
86 </body>
87 </html>