Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/index-validation-with-resized-buffer.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2010 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 <html>
7 <head>
8 <link rel="stylesheet" href="../resources/js-test-style.css"/>
9 <script src="../resources/js-test-pre.js"></script>
10 <script src="resources/webgl-test.js"></script>
11 </head>
12 <body>
13 <canvas id="example" width="1px" height="1px"></canvas>
14 <div id="description"></div>
15 <div id="console"></div>
16
17 <script id="vs" type="x-shader/x-vertex">
18 attribute vec4 vPosition;
19 attribute vec4 vColor;
20 varying vec4 color;
21 void main() {
22 gl_Position = vPosition;
23 color = vColor;
24 }
25 </script>
26 <script id="fs" type="x-shader/x-fragment">
27 #if defined(GL_ES)
28 precision mediump float;
29 #endif
30 varying vec4 color;
31 void main() {
32 gl_FragColor = color;
33 }
34 </script>
35 <script>
36 description('Test that updating the size of a vertex buffer is properly noticed by the WebGL implementation.')
37
38 var gl = initWebGL("example", "vs", "fs", ["vPosition", "vColor"], [0, 0, 0, 1], 1);
39 glErrorShouldBe(gl, gl.NO_ERROR, "after initialization");
40
41 gl.useProgram(gl.program);
42 var vertexObject = gl.createBuffer();
43 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
44 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
45 [-1,1,0, 1,1,0, -1,-1,0,
46 -1,-1,0, 1,1,0, 1,-1,0]), gl.STATIC_DRAW);
47 gl.enableVertexAttribArray(0);
48 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
49 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup");
50
51 var texCoordObject = gl.createBuffer();
52 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
53 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
54 [0,0, 1,0, 0,1,
55 0,1, 1,0, 1,1]), gl.STATIC_DRAW);
56 gl.enableVertexAttribArray(1);
57 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
58 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup");
59
60 // Now resize these buffers because we want to change what we're drawing.
61 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
62 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
63 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0,
64 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW);
65 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition");
66 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
67 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([
68 255, 0, 0, 255,
69 255, 0, 0, 255,
70 255, 0, 0, 255,
71 255, 0, 0, 255,
72 0, 255, 0, 255,
73 0, 255, 0, 255,
74 0, 255, 0, 255,
75 0, 255, 0, 255]), gl.STATIC_DRAW);
76 gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0);
77 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinition" );
78
79 var numQuads = 2;
80 var indices = new Uint8Array(numQuads * 6);
81 for (var ii = 0; ii < numQuads; ++ii) {
82 var offset = ii * 6;
83 var quad = (ii == (numQuads - 1)) ? 4 : 0;
84 indices[offset + 0] = quad + 0;
85 indices[offset + 1] = quad + 1;
86 indices[offset + 2] = quad + 2;
87 indices[offset + 3] = quad + 2;
88 indices[offset + 4] = quad + 1;
89 indices[offset + 5] = quad + 3;
90 }
91 var indexObject = gl.createBuffer();
92 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
93 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
94 glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
95 gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0);
96 glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
97
98 debug("")
99 successfullyParsed = true;
100 </script>
101
102 <script src="../resources/js-test-post.js"></script>
103 </body>
104 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698