4 <meta http-equiv='content-type' content='text/html; charset=utf-
8'
/>
6 <title>Test contents of uninitialized buffers
</title>
8 <script src='/tests/SimpleTest/SimpleTest.js'
></script>
9 <link rel='stylesheet' href='/tests/SimpleTest/test.css'
>
10 <script src='webgl-util.js'
></script>
18 var status
= gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
);
19 ok(status
== gl
.FRAMEBUFFER_COMPLETE
, 'FB should be complete.');
21 var pixel
= new Uint8Array(4);
22 gl
.readPixels(0, 0, 1, 1, gl
.RGBA
, gl
.UNSIGNED_BYTE
, pixel
);
24 ok(!pixel
[0], 'R channel should be 0, was ' + pixel
[0] + '.');
25 ok(!pixel
[1], 'G channel should be 0, was ' + pixel
[1] + '.');
26 ok(!pixel
[2], 'B channel should be 0, was ' + pixel
[2] + '.');
27 ok(!pixel
[3], 'A channel should be 0, was ' + pixel
[3] + '.');
30 function Test(contextAttribs
) {
31 ok(true, '===============================');
32 ok(true, 'Testing ' + JSON
.stringify(contextAttribs
));
34 var c
= document
.createElement('canvas');
35 var gl
= c
.getContext('webgl', contextAttribs
);
37 todo(false, 'WebGL is unavailable.');
41 var rb
= gl
.createRenderbuffer();
42 gl
.bindRenderbuffer(gl
.RENDERBUFFER
, rb
);
44 var tex
= gl
.createTexture();
45 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
47 var err
= gl
.getError();
48 ok(!err
, 'Error should be 0x0, was 0x' + err
.toString(16));
52 var fb
= gl
.createFramebuffer();
53 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
55 ok(true, 'Backed with RB');
56 gl
.framebufferRenderbuffer(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.RENDERBUFFER
, rb
);
57 gl
.renderbufferStorage(gl
.RENDERBUFFER
, gl
.RGBA4
, 1, 1);
60 ok(true, 'Backed with texture');
61 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
62 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA
, 1, 1, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
, null);
66 ok(!err
, 'Error should be 0x0, was 0x' + err
.toString(16));
69 // Give ourselves a scope to return early from:
71 // We test multiple configurations because we've had bugs regarding faking RGBX on
72 // ANGLE: With alpha:false, uninitialized buffers were being filled with (0,0,0,1)
73 // instead of (0,0,0,0).
74 Test({alpha
: false, antialias
: false});
75 Test({alpha
: true, antialias
: false});
76 Test({alpha
: false, antialias
: true});
77 Test({alpha
: true, antialias
: true});
79 ok(true, 'Test complete.');