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 Tests.testOk = function(gl) { |
| 43 var sh = new Filter(gl, 'okvert', 'frag'); |
| 44 assertOk(function(){sh.apply();}); |
| 45 sh.destroy(); |
| 46 |
| 47 var sh = new Filter(gl, 'vert', 'okfrag'); |
| 48 assertOk(function(){sh.apply();}); |
| 49 sh.destroy(); |
| 50 |
| 51 var sh = new Filter(gl, 'vert', 'frag'); |
| 52 assertOk(function(){sh.apply();}); |
| 53 sh.destroy(); |
| 54 } |
| 55 |
| 56 var arr = ['cr', 'cw', 'vr', 'vw']; |
| 57 arr.forEach(function(e){ |
| 58 Tests['test'+e+'vert'] = function(gl) { |
| 59 var sh = new Filter(gl, e+'vert', 'frag'); |
| 60 assertFail(function(){sh.apply();}); |
| 61 sh.destroy(); |
| 62 } |
| 63 Tests['test'+e+'frag'] = function(gl) { |
| 64 var sh = new Filter(gl, 'vert', e+'frag'); |
| 65 assertFail(function(){sh.apply();}); |
| 66 sh.destroy(); |
| 67 } |
| 68 }); |
| 69 |
| 70 |
| 71 </script> |
| 72 <script id="okvert" type="x-shader/x-vertex"> |
| 73 |
| 74 |
| 75 attribute vec3 Vertex; |
| 76 attribute vec2 Tex; |
| 77 varying vec2 TexCoord; |
| 78 void main() |
| 79 { |
| 80 TexCoord = Tex; |
| 81 float x[3]; |
| 82 x[0] = 1.0; |
| 83 x[1] = 2.0; |
| 84 x[2] = 3.0; |
| 85 gl_Position = vec4(Vertex, x[2]); |
| 86 } |
| 87 </script> |
| 88 <script id="crvert" type="x-shader/x-vertex"> |
| 89 |
| 90 |
| 91 attribute vec3 Vertex; |
| 92 attribute vec2 Tex; |
| 93 varying vec2 TexCoord; |
| 94 void main() |
| 95 { |
| 96 TexCoord = Tex; |
| 97 float x[3]; |
| 98 x[0] = 1.0; |
| 99 x[1] = 2.0; |
| 100 x[2] = 3.0; |
| 101 gl_Position = vec4(Vertex, x[4]); |
| 102 } |
| 103 </script> |
| 104 <script id="cwvert" type="x-shader/x-vertex"> |
| 105 |
| 106 |
| 107 attribute vec3 Vertex; |
| 108 attribute vec2 Tex; |
| 109 varying vec2 TexCoord; |
| 110 void main() |
| 111 { |
| 112 TexCoord = Tex; |
| 113 float x[3]; |
| 114 x[0] = 1.0; |
| 115 x[1] = 2.0; |
| 116 x[2] = 3.0; |
| 117 x[4] = Vertex.z; |
| 118 gl_Position = vec4(Vertex, x[4]); |
| 119 } |
| 120 </script> |
| 121 <script id="vrvert" type="x-shader/x-vertex"> |
| 122 |
| 123 |
| 124 attribute vec3 Vertex; |
| 125 attribute vec2 Tex; |
| 126 varying vec2 TexCoord; |
| 127 void main() |
| 128 { |
| 129 TexCoord = Tex; |
| 130 float x[3]; |
| 131 x[0] = 1.0; |
| 132 x[1] = 2.0; |
| 133 x[2] = 3.0; |
| 134 int idx = 4 * int(max(1.0, Vertex.x*20.0)); |
| 135 gl_Position = vec4(Vertex, x[idx]); |
| 136 } |
| 137 </script> |
| 138 <script id="vwvert" type="x-shader/x-vertex"> |
| 139 |
| 140 |
| 141 attribute vec3 Vertex; |
| 142 attribute vec2 Tex; |
| 143 varying vec2 TexCoord; |
| 144 void main() |
| 145 { |
| 146 TexCoord = Tex; |
| 147 float x[3]; |
| 148 x[0] = 1.0; |
| 149 x[1] = 2.0; |
| 150 x[2] = 3.0; |
| 151 int idx = 4 * int(max(1.0, Vertex.x*20.0)); |
| 152 x[idx] = Vertex.z; |
| 153 gl_Position = vec4(Vertex, x[idx]); |
| 154 } |
| 155 </script> |
| 156 <script id="vert" type="x-shader/x-vertex"> |
| 157 |
| 158 |
| 159 attribute vec3 Vertex; |
| 160 attribute vec2 Tex; |
| 161 varying vec2 TexCoord; |
| 162 void main() |
| 163 { |
| 164 TexCoord = Tex; |
| 165 gl_Position = vec4(Vertex, 0.0); |
| 166 } |
| 167 </script> |
| 168 |
| 169 <script id="okfrag" type="x-shader/x-fragment"> |
| 170 |
| 171 |
| 172 precision mediump float; |
| 173 |
| 174 varying vec2 TexCoord; |
| 175 |
| 176 void main() |
| 177 { |
| 178 float x[3]; |
| 179 x[0] = 1.0; |
| 180 x[1] = 2.0; |
| 181 x[2] = 3.0; |
| 182 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[2]); |
| 183 } |
| 184 </script> |
| 185 <script id="crfrag" type="x-shader/x-fragment"> |
| 186 |
| 187 |
| 188 precision mediump float; |
| 189 |
| 190 varying vec2 TexCoord; |
| 191 |
| 192 void main() |
| 193 { |
| 194 float x[3]; |
| 195 x[0] = 1.0; |
| 196 x[1] = 2.0; |
| 197 x[2] = 3.0; |
| 198 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[4]); |
| 199 } |
| 200 </script> |
| 201 <script id="cwfrag" type="x-shader/x-fragment"> |
| 202 |
| 203 |
| 204 precision mediump float; |
| 205 |
| 206 varying vec2 TexCoord; |
| 207 |
| 208 void main() |
| 209 { |
| 210 float x[3]; |
| 211 x[0] = 1.0; |
| 212 x[1] = 2.0; |
| 213 x[2] = 3.0; |
| 214 |
| 215 x[4] = 6.0; |
| 216 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[4]); |
| 217 } |
| 218 </script> |
| 219 <script id="vrfrag" type="x-shader/x-fragment"> |
| 220 |
| 221 |
| 222 precision mediump float; |
| 223 |
| 224 varying vec2 TexCoord; |
| 225 |
| 226 void main() |
| 227 { |
| 228 float x[3]; |
| 229 x[0] = 1.0; |
| 230 x[1] = 2.0; |
| 231 x[2] = 3.0; |
| 232 |
| 233 int idx = 4 * int(max(1.0, TexCoord.x*20.0)); |
| 234 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[idx]); |
| 235 } |
| 236 </script> |
| 237 <script id="vwfrag" type="x-shader/x-fragment"> |
| 238 |
| 239 |
| 240 precision mediump float; |
| 241 |
| 242 varying vec2 TexCoord; |
| 243 |
| 244 void main() |
| 245 { |
| 246 float x[3]; |
| 247 x[0] = 1.0; |
| 248 x[1] = 2.0; |
| 249 x[2] = 3.0; |
| 250 |
| 251 int idx = 4 * int(max(1.0, TexCoord.x*20.0)); |
| 252 x[idx] = 6.0; |
| 253 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[idx]); |
| 254 } |
| 255 </script> |
| 256 <script id="frag" type="x-shader/x-fragment"> |
| 257 |
| 258 |
| 259 precision mediump float; |
| 260 |
| 261 varying vec2 TexCoord; |
| 262 |
| 263 void main() |
| 264 { |
| 265 gl_FragColor = vec4(1.0, 0.0, TexCoord.s, 1.0); |
| 266 } |
| 267 </script> |
| 268 |
| 269 |
| 270 <style>canvas{ position:absolute; }</style> |
| 271 </head><body> |
| 272 <canvas id="gl" width="16" height="16"></canvas> |
| 273 </body></html> |
OLD | NEW |