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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/samplers/glsl-function-texture2dproj.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="32" height="32"></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader0" 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="fshader0" type="x-shader/x-vertex">
30 precision mediump float;
31 uniform sampler2D tex;
32 uniform float divisor;
33 varying vec2 texCoord;
34 void main() {
35 gl_FragData[0] = texture2DProj(tex, vec3(texCoord, divisor));
36 }
37 </script>
38 <script id="vshader1" type="x-shader/x-vertex">
39 attribute vec4 vPosition;
40 attribute vec2 texCoord0;
41 varying vec2 texCoord;
42 void main() {
43 gl_Position = vPosition;
44 texCoord = texCoord0;
45 }
46 </script>
47 <script id="fshader1" type="x-shader/x-vertex">
48 precision mediump float;
49 uniform sampler2D tex;
50 uniform float divisor;
51 varying vec2 texCoord;
52 void main() {
53 gl_FragData[0] = texture2DProj(tex, vec4(texCoord, 123.0, divisor));
54 }
55 </script>
56 <script>
57 description("tests GLSL texture2DProj function with");
58
59 var wtu = WebGLTestUtils;
60 var canvas = document.getElementById("example");
61
62 var gl = wtu.create3DContext(canvas, {antialias: false});
63
64 wtu.setupUnitQuad(gl, 0, 1);
65 var tex = gl.createTexture();
66 gl.bindTexture(gl.TEXTURE_2D, tex);
67 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
68 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
69 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
70 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
71
72 var c = document.createElement("canvas");
73 c.width = 16;
74 c.height = 16;
75 var ctx = c.getContext("2d");
76 ctx.fillStyle = "rgb(0,255,0)";
77 ctx.fillRect(0, 0, 16, 16);
78 ctx.fillStyle = "rgb(0,0,255)";
79 ctx.fillRect(0, 0, 8, 8);
80 ctx.fillRect(8, 8, 8, 8);
81
82 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
83
84 for (var ss = 0; ss < 2; ++ss) {
85 debug("");
86 debug(ss ? "testing vec4 version" : "testing vec3 version");
87 var program = wtu.setupProgram(
88 gl,
89 [wtu.loadShaderFromScript(gl, 'vshader' + ss, gl.VERTEX_SHADER),
90 wtu.loadShaderFromScript(gl, 'fshader' + ss, gl.FRAGMENT_SHADER)],
91 ['vPosition', 'texCoord0'], [0, 1]);
92 gl.useProgram(program);
93 var loc = gl.getUniformLocation(program, "divisor");
94
95 for (var ii = 0; ii < 3; ++ii) {
96 var denominator = Math.pow(2, ii);
97 gl.uniform1f(loc, 1 / denominator);
98 wtu.drawQuad(gl);
99 var size = 16 / denominator;
100 for (var yy = 0; yy < 32; yy += size) {
101 for (var xx = 0; xx < 32; xx += size) {
102 var odd = (xx / size + yy / size) % 2;
103 var color = odd ? [0, 255, 0, 255] : [0, 0, 255, 255];
104 var msg = "" + xx + ", " + yy + ", " + size + ", " + size + " sh ould be " + (odd ? "green" : "blue");
105 wtu.checkCanvasRect(gl, xx, yy, size, size, color, msg);
106 }
107 }
108 }
109 }
110 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
111
112 successfullyParsed = true;
113
114 </script>
115 <script src="../../../resources/js-test-post.js"></script>
116
117 </body>
118 </html>
119
120
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698