|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>WebGL test: Check for error on ReadPixels from a depth-only FB.</title> |
|
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 <script src="driver-info.js"></script> |
|
9 </head> |
|
10 <body> |
|
11 <canvas id="c"></canvas> |
|
12 <script> |
|
13 "use strict"; |
|
14 |
|
15 (function() { |
|
16 var gl = WebGLUtil.getWebGL('c'); |
|
17 if (!gl) { |
|
18 todo(gl, 'Get GL working here first.'); |
|
19 return; |
|
20 } |
|
21 |
|
22 var rb = gl.createRenderbuffer(); |
|
23 gl.bindRenderbuffer(gl.RENDERBUFFER, rb); |
|
24 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 4, 4); |
|
25 |
|
26 var fb = gl.createFramebuffer(); |
|
27 gl.bindFramebuffer(gl.FRAMEBUFFER, fb); |
|
28 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, |
|
29 gl.RENDERBUFFER, rb); |
|
30 |
|
31 if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { |
|
32 todo(false, 'Depth-only FB incomplete. This is valid.'); |
|
33 return; |
|
34 } |
|
35 |
|
36 ok(!gl.getError(), 'Should have no errors after constructing FB.'); |
|
37 |
|
38 var pixels = new Uint8Array([1, 2, 3, 4]); |
|
39 gl.readPixels(0, 0, // x,y |
|
40 1, 1, // w,h |
|
41 gl.RGBA, gl.UNSIGNED_BYTE, pixels); |
|
42 |
|
43 ok(gl.getError() == gl.INVALID_OPERATION, |
|
44 '1x1 color read from a depth FB should generated INVALID_OP.'); |
|
45 console.log('Data after 1x1 color-from-depth readpixels:'); |
|
46 console.log(pixels); |
|
47 |
|
48 gl.readPixels(0, 0, // x,y |
|
49 0, 0, // w,h |
|
50 gl.RGBA, gl.UNSIGNED_BYTE, pixels); |
|
51 |
|
52 ok(gl.getError() == gl.INVALID_OPERATION, |
|
53 '0x0 color read from a depth FB should generated INVALID_OP.'); |
|
54 })(); |
|
55 |
|
56 ok(true, 'Test complete.'); |
|
57 |
|
58 </script> |
|
59 </body> |
|
60 </html> |