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 = wrapGLContext(canvas.getContext(GL_CONTEXT_ID)); |
| 39 gl.viewport(0,0,canvas.width,canvas.height); |
| 40 gl.clearColor(0,0,1,1); |
| 41 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
| 42 gl.disable(gl.DEPTH_TEST); |
| 43 return [gl]; |
| 44 } |
| 45 |
| 46 Tests.setup = function(gl) { |
| 47 var tex = gl.createTexture(); |
| 48 gl.bindTexture(gl.TEXTURE_2D, tex); |
| 49 var texCubeMap = gl.createTexture(); |
| 50 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap); |
| 51 return [gl] |
| 52 } |
| 53 |
| 54 Tests.teardown = function(gl, tex, texCubeMap) { |
| 55 gl.bindTexture(gl.TEXTURE_2D, null); |
| 56 gl.deleteTexture(tex); |
| 57 gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); |
| 58 gl.deleteTexture(texCubeMap); |
| 59 } |
| 60 |
| 61 Tests.testTexImage2D = function(gl) { |
| 62 gl.enable(gl.BLEND); |
| 63 var img = document.getElementById('i'); |
| 64 var c = document.getElementById('c'); |
| 65 var ctx = c.getContext('2d'); |
| 66 ctx.drawImage(img,0,0); |
| 67 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img); |
| 68 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
| 69 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
| 70 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); |
| 71 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); |
| 72 var f = new Filter(gl, 'identity-flip-vert', 'identity-frag'); |
| 73 gl.blendFunc(gl.ONE, gl.ZERO); |
| 74 f.apply(); |
| 75 f.destroy(); |
| 76 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 77 f = new Filter(gl, 'identity-hflip-vert', 'identity-frag'); |
| 78 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); |
| 79 f.apply(); |
| 80 f.destroy(); |
| 81 var valid_targets = [ |
| 82 gl.TEXTURE_2D, |
| 83 gl.TEXTURE_CUBE_MAP_POSITIVE_X, |
| 84 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 85 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, |
| 86 gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| 87 gl.TEXTURE_CUBE_MAP_POSITIVE_Z, |
| 88 gl.TEXTURE_CUBE_MAP_NEGATIVE_Z |
| 89 ]; |
| 90 valid_targets.forEach(function(t) { |
| 91 assertOk(function(){gl.texImage2D(t, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BY
TE, c);}); |
| 92 assertOk(function(){gl.texImage2D(t, 1, gl.RGBA, gl.RGBA, gl.UNSIGNED_BY
TE, c);}); |
| 93 }); |
| 94 } |
| 95 |
| 96 Tests.testTexImage2DNonSOP = function(gl) { |
| 97 var img = document.getElementById('i2'); |
| 98 while (!img.complete) {} |
| 99 var c = document.getElementById('c'); |
| 100 var ctx = c.getContext('2d'); |
| 101 ctx.drawImage(img,0,0); |
| 102 assertThrowNoGLError(gl, "texImage2D with cross-origin image should throw ex
ception.", |
| 103 function(){gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_B
YTE, img);}); |
| 104 assertThrowNoGLError(gl, "texImage2D with dirty origin canvas should throw e
xception.", |
| 105 function(){gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_B
YTE, c);}); |
| 106 } |
| 107 |
| 108 Tests.endUnit = function(gl) { |
| 109 } |
| 110 |
| 111 </script> |
| 112 <script id="identity-flip-vert" type="x-shader/x-vertex"> |
| 113 attribute vec3 Vertex; |
| 114 attribute vec2 Tex; |
| 115 |
| 116 varying vec4 texCoord0; |
| 117 void main() |
| 118 { |
| 119 texCoord0 = vec4(Tex.s, 1.0-Tex.t, 0.0, 0.0); |
| 120 gl_Position = vec4(Vertex, 1.0); |
| 121 } |
| 122 </script> |
| 123 <script id="identity-hflip-vert" type="x-shader/x-vertex"> |
| 124 attribute vec3 Vertex; |
| 125 attribute vec2 Tex; |
| 126 |
| 127 varying vec4 texCoord0; |
| 128 void main() |
| 129 { |
| 130 texCoord0 = vec4(1.0-Tex.s, Tex.t, 0.0, 0.0); |
| 131 gl_Position = vec4(Vertex, 1.0); |
| 132 } |
| 133 </script> |
| 134 <script id="identity-frag" type="x-shader/x-fragment"> |
| 135 precision mediump float; |
| 136 |
| 137 uniform sampler2D Texture; |
| 138 |
| 139 varying vec4 texCoord0; |
| 140 void main() |
| 141 { |
| 142 vec4 c = texture2D(Texture, texCoord0.st); |
| 143 gl_FragColor = c; |
| 144 } |
| 145 </script> |
| 146 </head><body> |
| 147 <canvas id="gl" width="256" height="256"></canvas> |
| 148 <canvas id="c" width="256" height="256"></canvas> |
| 149 <img id="i" width="256" height="256" src="data:image/png;base64,iVBORw0KGgoAAAA
NSUhEUgAAAQAAAAEACAYAAABccqhmAAATVElEQVR4nO3d+VPUd57Hcf2b9k9Y+z44+qK7OZoGFVA5VfB
Gzah9cxpNzGEOoRua5lBEue/DK4fZ7MapmSm3Mlshu8xOdCpDJt3v/aEBAUHAOMG4z0fV53fqU/V6fd7
fT/e32bEDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAwOvBkar7l+3+GwBsk8xUrT0rTb8vx2Q45janlu7YsWPnsgXgTeYwak85U3Xv5ZiM3+XbUh/
l2dICBc6080WZ1ur92baSHRQB8GayGdUWu1HzoSNFO+ZM1f2cbTLM51lT5woc5rkDObbZ/Vm2SEm23Vv
syjhV5nJQBsCbxGZQVtmN6p4Mo/YPdqNGHKlayUrXJ9zWlESh0xIvzsmYL3HZ54pzMm6VuRyRMpfTW+p
yUAbAm8BmVNVnG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