test_depth_tex_lazy_clear.html (1541B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset='utf-8'/> 5 <script src='/tests/SimpleTest/SimpleTest.js'></script> 6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'> 7 <script src='webgl-util.js'></script> 8 </head> 9 <body> 10 <script id='vs' type='x-shader/x-vertex'> 11 12 attribute vec2 aVertCoord; 13 14 void main(void) { 15 gl_Position = vec4(aVertCoord, 0.0, 1.0); 16 } 17 18 </script> 19 <script id='fs' type='x-shader/x-fragment'> 20 21 precision mediump float; 22 uniform sampler2D uTexUnit; 23 24 void main(void) { 25 vec4 tex = texture2D(uTexUnit, vec2(0)); 26 gl_FragColor = vec4(tex.r, 1.0, 0.0, 1.0); 27 } 28 29 </script> 30 <script> 31 'use strict'; 32 33 var gl = null; 34 35 do { 36 var c = document.createElement('canvas'); 37 gl = c.getContext('webgl'); 38 if (!gl) { 39 todo(false, 'Get GL working here first.'); 40 break; 41 } 42 43 var ext = gl.getExtension('WEBGL_depth_texture'); 44 if (!ext) { 45 todo(false, 'WEBGL_depth_texture not supported, which is fine.'); 46 break; 47 } 48 49 var prog = WebGLUtil.createProgramByIds(gl, 'vs', 'fs'); 50 if (!prog) { 51 ok(false, 'Program linking should succeed.'); 52 break; 53 } 54 55 var tex = gl.createTexture(); 56 gl.bindTexture(gl.TEXTURE_2D, tex); 57 gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 1, 1, 0, gl.DEPTH_COMPONENT, 58 gl.UNSIGNED_INT, null); 59 60 var uTexUnit = gl.getUniformLocation(prog, 'uTexUnit'); 61 gl.useProgram(prog); 62 gl.uniform1i(uTexUnit, 0); 63 64 gl.drawArrays(gl.POINTS, 0, 1); 65 66 ok(!gl.getError(), 'Should have no errors.'); 67 } while (false); 68 69 ok(true, 'Test complete.'); 70 71 </script> 72 </body> 73 </html>