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

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

Powered by Google App Engine
This is Rietveld 408576698