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>
11 <canvas id=
"c"></canvas>
16 var gl
= c
.getContext('webgl');
18 todo(gl
, 'Get GL working here first.');
22 var rb
= gl
.createRenderbuffer();
23 gl
.bindRenderbuffer(gl
.RENDERBUFFER
, rb
);
24 gl
.renderbufferStorage(gl
.RENDERBUFFER
, gl
.DEPTH_COMPONENT16
, 4, 4);
26 var fb
= gl
.createFramebuffer();
27 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
28 gl
.framebufferRenderbuffer(gl
.FRAMEBUFFER
, gl
.DEPTH_ATTACHMENT
,
31 if (gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
) != gl
.FRAMEBUFFER_COMPLETE
) {
32 todo(false, 'Depth-only FB incomplete. This is valid.');
36 ok(!gl
.getError(), 'Should have no errors after constructing FB.');
38 var pixels
= new Uint8Array([1, 2, 3, 4]);
39 gl
.readPixels(0, 0, // x,y
41 gl
.RGBA
, gl
.UNSIGNED_BYTE
, pixels
);
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:');
48 gl
.readPixels(0, 0, // x,y
50 gl
.RGBA
, gl
.UNSIGNED_BYTE
, pixels
);
52 ok(gl
.getError() == gl
.INVALID_OPERATION
,
53 '0x0 color read from a depth FB should generated INVALID_OP.');
56 ok(true, 'Test complete.');