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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/rendering/point-size.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
33 <script src="../../resources/js-test-pre.js"></script>
34 <script src="../resources/webgl-test.js"></script>
35 <script id="vshader" type="x-shader/x-vertex">
36 attribute vec3 pos;
37 attribute vec4 colorIn;
38 uniform float pointSize;
39 varying vec4 color;
40
41 void main()
42 {
43 gl_PointSize = pointSize;
44 color = colorIn;
45 gl_Position = vec4(pos, 1.0);
46 }
47 </script>
48
49 <script id="fshader" type="x-shader/x-fragment">
50 precision mediump float;
51 varying vec4 color;
52
53 void main()
54 {
55 gl_FragColor = color;
56 }
57 </script>
58 </head>
59 <body>
60 <canvas id="testbed" width="2px" height="2px"></canvas>
61 <div id="description"></div>
62 <div id="console"></div>
63 <script>
64 description('Verify GL_VERTEX_PROGRAM_POINT_SIZE is enabled in WebGL');
65
66 var gl = initWebGL('testbed', { antialias: false });
67 shouldBeNonNull("gl");
68 var program = setupProgram(gl, 'vshader', 'fshader', ['pos', 'colorIn']);
69 shouldBe('gl.getError()', 'gl.NO_ERROR');
70
71 gl.disable(gl.BLEND);
72 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
73
74 // The choice of (0.4, 0.4) ensures that the centers of the surrounding
75 // pixels are not contained within the point when it is of size 1, but
76 // that they definitely are when it is of size 2.
77 var vertices = new Float32Array([
78 0.4, 0.4, 0.0]);
79 var colors = new Uint8Array([
80 255, 0, 0, 255]);
81
82 var colorOffset = vertices.byteLength;
83
84 var vbo = gl.createBuffer();
85 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
86 gl.bufferData(gl.ARRAY_BUFFER, colorOffset + colors.byteLength, gl.STATIC_DR AW);
87 gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices);
88 gl.bufferSubData(gl.ARRAY_BUFFER, colorOffset, colors);
89
90 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
91 gl.enableVertexAttribArray(0);
92 gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 0, colorOffset);
93 gl.enableVertexAttribArray(1);
94
95 var locPointSize = gl.getUniformLocation(program, 'pointSize');
96
97 shouldBe('gl.getError()', 'gl.NO_ERROR');
98
99 debug('Draw a point of size 1 and verify it does not touch any other pixels. ');
100
101 gl.uniform1f(locPointSize, 1.0);
102 gl.drawArrays(gl.POINTS, 0, vertices.length / 3);
103 var buf = new Uint8Array(2 * 2 * 4);
104 gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
105 shouldBe('gl.getError()', 'gl.NO_ERROR');
106
107 var index = 0;
108 var correctColor;
109 for (var y = 0; y < 2; ++y) {
110 for (var x = 0; x < 2; ++x) {
111 correctColor = [0, 0, 0];
112 if (x == 1 && y == 1)
113 shouldBe('buf[index]', '255');
114 else
115 shouldBe('buf[index]', '0');
116 shouldBe('buf[index + 1]', '0');
117 shouldBe('buf[index + 2]', '0');
118 index += 4;
119 }
120 }
121 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
122
123 debug('Draw a point of size 2 and verify it fills the appropriate region.');
124
125 var pointSizeRange = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
126 if (pointSizeRange[1] >= 2.0) {
127 gl.uniform1f(locPointSize, 2.0);
128 gl.drawArrays(gl.POINTS, 0, vertices.length / 3);
129 gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
130 shouldBe('gl.getError()', 'gl.NO_ERROR');
131 index = 0;
132 for (var y = 0; y < 2; ++y) {
133 for (var x = 0; x < 2; ++x) {
134 shouldBe('buf[index]', '255');
135 shouldBe('buf[index + 1]', '0');
136 shouldBe('buf[index + 2]', '0');
137 index += 4;
138 }
139 }
140 }
141
142 successfullyParsed = true;
143 </script>
144
145 <script src="../../resources/js-test-post.js"></script>
146
147 </body>
148 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698