summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/state/fb-attach-implicit-target-assignment.html
blob: 1247c1f85693b5859c6f502afaa15212f454ea19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>WebGL gl calls Conformance Tests</title>
<link rel='stylesheet' href='../../resources/js-test-style.css'/>
<script src='../../js/js-test-pre.js'></script>
<script src='../../js/webgl-test-utils.js'></script>
</head>
<body>
<div id='description'></div>
<div id='console'></div>
<canvas id='canvas' width='2' height='2'> </canvas>
<script>
'use strict';
description('Test implicit target assignment during FB attachment');

const wtu = WebGLTestUtils;
const gl = wtu.create3DContext('canvas');
let fb, rb, tex;

(() => {
    if (!gl) {
        testFailed('context does not exist');
        return;
    }

    fb = gl.createFramebuffer();
    gl.bindFramebuffer(gl.FRAMEBUFFER, fb);

    wtu.glErrorShouldBe(gl, 0, 'No errors');

    // -

    debug('');
    debug('framebufferRenderbuffer');

    rb = gl.createRenderbuffer();
    shouldBe('gl.isRenderbuffer(rb)', 'false');
    gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
    shouldBe('gl.isRenderbuffer(rb)', 'true');

    rb = gl.createRenderbuffer();
    shouldBe('gl.isRenderbuffer(rb)', 'false');
    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rb);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, 'framebufferRenderbuffer must be preceeded by some bindRenderbuffer');
    shouldBe('gl.isRenderbuffer(rb)', 'false');

    wtu.glErrorShouldBe(gl, 0, 'No errors');

    // -

    debug('');
    debug('framebufferTexture2D');

    tex = gl.createTexture();
    shouldBe('gl.isTexture(tex)', 'false');
    gl.bindTexture(gl.TEXTURE_2D, tex);
    shouldBe('gl.isTexture(tex)', 'true');

    tex = gl.createTexture();
    shouldBe('gl.isTexture(tex)', 'false');
    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
    // https://bugzilla.mozilla.org/show_bug.cgi?id=1636524 :
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, 'framebufferTexture2D must be preceeded by some bindTexture');
    shouldBe('gl.isTexture(tex)', 'false');

    gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
    wtu.glErrorShouldBe(gl, 0, 'No errors after bindTexture');

    tex = gl.createTexture();
    shouldBe('gl.isTexture(tex)', 'false');
    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X, tex, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, 'framebufferTexture2D must be preceeded by some bindTexture');
    shouldBe('gl.isTexture(tex)', 'false');

    gl.bindTexture(gl.TEXTURE_2D, tex);
    wtu.glErrorShouldBe(gl, 0, 'No errors after bindTexture');
})();

debug('');
var successfullyParsed = true;

</script>
<script src='../../js/js-test-post.js'></script>

</body>
</html>