OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html><head> | |
3 <meta charset="utf-8"> | |
4 <!-- | |
5 Tests for the OpenGL ES 2.0 HTML Canvas context | |
6 | |
7 Copyright (C) 2011 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> | |
8 | |
9 Permission is hereby granted, free of charge, to any person | |
10 obtaining a copy of this software and associated documentation | |
11 files (the "Software"), to deal in the Software without | |
12 restriction, including without limitation the rights to use, | |
13 copy, modify, merge, publish, distribute, sublicense, and/or sell | |
14 copies of the Software, and to permit persons to whom the | |
15 Software is furnished to do so, subject to the following | |
16 conditions: | |
17 | |
18 The above copyright notice and this permission notice shall be | |
19 included in all copies or substantial portions of the Software. | |
20 | |
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
23 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
25 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
28 OTHER DEALINGS IN THE SOFTWARE. | |
29 | |
30 --> | |
31 <link rel="stylesheet" type="text/css" href="../unit.css" /> | |
32 <script type="application/x-javascript" src="../unit.js"></script> | |
33 <script type="application/x-javascript" src="../util.js"></script> | |
34 <script type="application/x-javascript"> | |
35 | |
36 Tests.startUnit = function () { | |
37 var canvas = document.getElementById('gl'); | |
38 var gl = canvas.getContext(GL_CONTEXT_ID); | |
39 return [gl]; | |
40 } | |
41 | |
42 var arr = ['cr', 'cw', 'vr', 'vw', 'tvw']; | |
43 arr.forEach(function(e){ | |
44 Tests['test'+e+'vert'] = function(gl) { | |
45 var sh = new Filter(gl, e+'vert', 'frag'); | |
46 assertFail(function(){sh.apply(function(f){ | |
47 f.uniform3fv('x', [0.0, 1.0, 2.0]); | |
48 throwError(e+"vert"); | |
49 });}); | |
50 sh.destroy(); | |
51 } | |
52 Tests['test'+e+'frag'] = function(gl) { | |
53 var sh = new Filter(gl, 'vert', e+'frag'); | |
54 assertFail(function(){sh.apply(function(f){ | |
55 f.uniform3fv('x', [0.0, 1.0, 2.0]); | |
56 throwError(e+"frag"); | |
57 });}); | |
58 sh.destroy(); | |
59 } | |
60 }); | |
61 | |
62 </script> | |
63 <script id="crvert" type="x-shader/x-vertex"> | |
64 | |
65 | |
66 attribute vec3 Vertex; attribute vec2 Tex; | |
67 uniform float x[3]; | |
68 void main() | |
69 { | |
70 gl_Position = vec4(Vertex.st, Tex.s, x[4]); | |
71 } | |
72 </script> | |
73 <script id="cwvert" type="x-shader/x-vertex"> | |
74 | |
75 | |
76 attribute vec3 Vertex; attribute vec2 Tex; | |
77 uniform float x[3]; | |
78 void main() | |
79 { | |
80 x[4] = Vertex.z; | |
81 gl_Position = vec4(Vertex.st, Tex.s, x[4]); | |
82 } | |
83 </script> | |
84 <script id="vrvert" type="x-shader/x-vertex"> | |
85 | |
86 | |
87 uniform float x[3]; | |
88 attribute vec3 Vertex; attribute vec2 Tex; | |
89 void main() | |
90 { | |
91 float idx = 40.0 * max(1.0, Vertex.x*20.0); | |
92 gl_Position = vec4(Vertex, x[2] + Tex.s + x[int(idx)]); | |
93 } | |
94 </script> | |
95 <script id="vwvert" type="x-shader/x-vertex"> | |
96 | |
97 | |
98 attribute vec3 Vertex; attribute vec2 Tex; | |
99 uniform float x[3]; | |
100 void main() | |
101 { | |
102 int idx = 4 * int(max(1.0, Vertex.x*20.0)); | |
103 x[idx] = Vertex.z; | |
104 gl_Position = vec4(Vertex.st, Tex.s, x[idx]); | |
105 } | |
106 </script> | |
107 <script id="tvwvert" type="x-shader/x-vertex"> | |
108 | |
109 | |
110 attribute vec3 Vertex; attribute vec2 Tex; | |
111 uniform float x[3]; | |
112 void main() | |
113 { | |
114 int idx = 4 * int(max(1.0, Vertex.x*20.0)); | |
115 x[2] = Vertex[idx]; | |
116 gl_Position = vec4(Vertex.st, Tex.s, x[2]); | |
117 } | |
118 </script> | |
119 <script id="vert" type="x-shader/x-vertex"> | |
120 | |
121 | |
122 attribute vec3 Vertex; attribute vec2 Tex; | |
123 varying vec2 TexCoord; | |
124 void main() | |
125 { | |
126 TexCoord = Vertex.st; | |
127 gl_Position = vec4(Vertex, Tex.s); | |
128 } | |
129 </script> | |
130 | |
131 <script id="crfrag" type="x-shader/x-fragment"> | |
132 | |
133 | |
134 precision mediump float; | |
135 | |
136 uniform float x[3]; | |
137 | |
138 varying vec2 TexCoord; | |
139 void main() | |
140 { | |
141 gl_FragColor = vec4(1.0, 0.0, 0.0, x[4]); | |
142 } | |
143 </script> | |
144 <script id="cwfrag" type="x-shader/x-fragment"> | |
145 | |
146 | |
147 precision mediump float; | |
148 | |
149 uniform float x[3]; | |
150 | |
151 varying vec2 TexCoord; | |
152 void main() | |
153 { | |
154 x[4] = 6.0; | |
155 gl_FragColor = vec4(1.0, 0.0, 0.0, x[4]); | |
156 } | |
157 </script> | |
158 <script id="vrfrag" type="x-shader/x-fragment"> | |
159 | |
160 | |
161 precision mediump float; | |
162 | |
163 uniform float x[3]; | |
164 | |
165 varying vec2 TexCoord; | |
166 void main() | |
167 { | |
168 int idx = 4 * int(max(1.0, TexCoord.s*20.0)); | |
169 gl_FragColor = vec4(1.0, 0.0, 0.0, x[idx]); | |
170 } | |
171 </script> | |
172 <script id="vwfrag" type="x-shader/x-fragment"> | |
173 | |
174 | |
175 precision mediump float; | |
176 | |
177 uniform float x[3]; | |
178 | |
179 varying vec2 TexCoord; | |
180 void main() | |
181 { | |
182 int idx = 4 * int(max(1.0, TexCoord.s*20.0)); | |
183 x[idx] = 6.0; | |
184 gl_FragColor = vec4(1.0, 0.0, 0.0, x[idx]); | |
185 } | |
186 </script> | |
187 <script id="tvwfrag" type="x-shader/x-fragment"> | |
188 | |
189 | |
190 precision mediump float; | |
191 | |
192 uniform float x[3]; | |
193 | |
194 varying vec2 TexCoord; | |
195 void main() | |
196 { | |
197 int idx = 4 * int(max(1.0, TexCoord.s*20.0)); | |
198 x[2] = TexCoord[idx]; | |
199 gl_FragColor = vec4(1.0, 0.0, 0.0, x[2]); | |
200 } | |
201 </script> | |
202 <script id="frag" type="x-shader/x-fragment"> | |
203 | |
204 | |
205 precision mediump float; | |
206 | |
207 void main() | |
208 { | |
209 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); | |
210 } | |
211 </script> | |
212 | |
213 | |
214 <style>canvas{ position:absolute; }</style> | |
215 </head><body> | |
216 <canvas id="gl" width="1" height="1"></canvas> | |
217 </body></html> | |
OLD | NEW |