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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/variables/gl-fragcoord.html

Issue 9373009: Check in webgl conformance tests r16844 from khronos. (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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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>gl-fragcoord Test</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="32" height="32">
18 </canvas>
19 <div id="description"></div>
20 <div id="console"></div>
21 <script id="vshader" type="x-shader/x-vertex">
22 attribute vec4 vPosition;
23 void main()
24 {
25 gl_Position = vPosition;
26 }
27 </script>
28
29 <script id="fshader" type="x-shader/x-fragment">
30 precision mediump float;
31 void main()
32 {
33 gl_FragColor = vec4(
34 floor(gl_FragCoord.x * 4.0 / 32.0) / 4.0,
35 floor(gl_FragCoord.y * 4.0 / 32.0) / 4.0,
36 floor(gl_FragCoord.z * 4.0) / 4.0,
37 1);
38 }
39 </script>
40
41 <script>
42 function init()
43 {
44 if (window.initNonKhronosFramework) {
45 window.initNonKhronosFramework(false);
46 }
47
48 description("tests gl_FragCoord");
49
50 wtu = WebGLTestUtils;
51 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
52
53 var vertexObject = gl.createBuffer();
54 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
55 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
56 [-1, -1, -1, 1, -1, 0, -1, 1, 0,
57 -1, 1, 0, 1, -1, 0, 1, 1, 1]),
58 gl.STATIC_DRAW);
59 gl.enableVertexAttribArray(0);
60 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
61
62 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
63 gl.drawArrays(gl.TRIANGLES, 0, 6);
64 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
65
66 for (var xx = 0; xx < 32; xx += 4) {
67 for (var yy = 0; yy < 32; yy += 4) {
68 var zz = (xx / 64) + (yy / 64);
69 var color = [
70 Math.floor(Math.floor(xx * 4.0 / 32.0) / 4 * 256),
71 Math.floor(Math.floor(yy * 4.0 / 32.0) / 4 * 256),
72 Math.floor(Math.floor(zz * 4.0) / 4 * 256)
73 ];
74 var msg = "should be " + color;
75 wtu.checkCanvasRect(
76 gl, xx, yy, 1, 1, color, msg, 4);
77 }
78 }
79 }
80
81 init();
82 successfullyParsed = true;
83 </script>
84 <script src="../../../resources/js-test-post.js"></script>
85
86 </body>
87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698