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: conformance/glsl/variables/gl-fragcoord.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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:executable
+ *
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 wtu = WebGLTestUtils;
49 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
50
51 var vertexObject = gl.createBuffer();
52 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
53 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
54 [-1, -1, -1, 1, -1, 0, -1, 1, 0,
55 -1, 1, 0, 1, -1, 0, 1, 1, 1]),
56 gl.STATIC_DRAW);
57 gl.enableVertexAttribArray(0);
58 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
59
60 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
61 gl.drawArrays(gl.TRIANGLES, 0, 6);
62 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
63
64 for (var xx = 0; xx < 32; xx += 4) {
65 for (var yy = 0; yy < 32; yy += 4) {
66 var zz = (xx / 64) + (yy / 64);
67 var color = [
68 Math.floor(Math.floor(xx * 4.0 / 32.0) / 4 * 256),
69 Math.floor(Math.floor(yy * 4.0 / 32.0) / 4 * 256),
70 Math.floor(Math.floor(zz * 4.0) / 4 * 256)
71 ];
72 var msg = "should be " + color;
73 wtu.checkCanvasRect(
74 gl, xx, yy, 1, 1, color, msg, 4);
75 }
76 }
77 }
78
79 init();
80 successfullyParsed = true;
81 </script>
82 <script src="../../../resources/js-test-post.js"></script>
83
84 </body>
85 </html>
OLDNEW
« no previous file with comments | « conformance/glsl/variables/00_test_list.txt ('k') | conformance/glsl/variables/gl-frontfacing.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698