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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/samplers/glsl-function-texture2d-bias.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>WebGL texture2D GLSL conformance 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="256" height="256" style="width: 16px; height: 16px;" ></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader2d" type="x-shader/x-vertex">
21 attribute vec4 vPosition;
22 attribute vec2 texCoord0;
23 varying vec2 texCoord;
24 void main() {
25 gl_Position = vPosition;
26 texCoord = texCoord0;
27 }
28 </script>
29 <script id="fshader2d" type="x-shader/x-vertex">
30 precision mediump float;
31 uniform sampler2D tex;
32 uniform float bias;
33 varying vec2 texCoord;
34 void main() {
35 gl_FragData[0] = texture2D(tex, texCoord, bias);
36 }
37 </script>
38 <script>
39 description("tests GLSL texture2D function with bias");
40
41 var wtu = WebGLTestUtils;
42 var canvas = document.getElementById("example");
43
44 shouldBe("canvas.width", "256");
45 shouldBe("canvas.height", "256");
46
47 var gl = wtu.create3DContext(canvas);
48 var program = wtu.setupProgram(
49 gl,
50 [wtu.loadShaderFromScript(gl, 'vshader2d', gl.VERTEX_SHADER),
51 wtu.loadShaderFromScript(gl, 'fshader2d', gl.FRAGMENT_SHADER)],
52 ['vPosition', 'texCoord0'], [0, 1]);
53 wtu.setupUnitQuad(gl, 0, 1);
54
55 var colors = [
56 {name: 'red', color:[255, 0, 0, 255]},
57 {name: 'green', color:[0, 255, 0, 255]},
58 {name: 'blue', color:[0, 0, 255, 255]},
59 {name: 'yellow', color:[255, 255, 0, 255]},
60 {name: 'magenta', color:[255, 0, 255, 255]},
61 {name: 'cyan', color:[0, 255, 255, 255]},
62 {name: 'pink', color:[255, 128, 128, 255]},
63 {name: 'gray', color:[128, 128, 128, 255]},
64 {name: 'light green', color:[128, 255, 128, 255]},
65 ];
66
67 shouldBe("colors.length", "9");
68
69 var tex = gl.createTexture();
70 gl.bindTexture(gl.TEXTURE_2D, tex);
71 gl.texParameteri(
72 gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
73 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
74 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
75 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
76
77 for (var ii = 0; ii < colors.length; ++ii) {
78 var color = colors[ii];
79 var size = Math.pow(2, colors.length - ii - 1);
80 wtu.fillTexture(gl, tex, size, size, color.color, ii);
81 }
82
83 var loc = gl.getUniformLocation(program, "bias");
84
85 for (var ii = 0; ii < colors.length; ++ii) {
86 gl.uniform1f(loc, ii);
87 var color = colors[ii];
88 wtu.drawQuad(gl);
89 wtu.checkCanvas(
90 gl, color.color,
91 "256x256 texture drawn to 256x256 dest with bias = " + ii +
92 " should be " + color.name);
93 }
94 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
95
96 successfullyParsed = true;
97
98 </script>
99 <script src="../../../resources/js-test-post.js"></script>
100
101 </body>
102 </html>
103
104
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698