File: test_framebuffer_clear.py

package info (click to toggle)
python-moderngl 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,700 kB
  • sloc: python: 15,758; cpp: 14,665; makefile: 14
file content (24 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

def test_1(ctx):
    fbo1 = ctx.simple_framebuffer((4, 4))
    fbo2 = ctx.simple_framebuffer((4, 4))

    fbo1.clear(0.0, 0.0, 0.0, 0.0)

    assert fbo1.read() == b'\x00\x00\x00' * 4 * 4

    fbo1.clear(1.0, 0.0, 0.0, 0.0, viewport=(2, 2))
    fbo1.clear(0.0, 1.0, 0.0, 0.0, viewport=(2, 0, 2, 2))
    fbo1.clear(0.0, 0.0, 1.0, 0.0, viewport=(0, 2, 2, 2))

    assert fbo1.read((2, 2)), b'\xff\x00\x00' * 2 * 2
    assert fbo1.read((2, 0, 2, 2)), b'\x00\xff\x00' * 2 * 2
    assert fbo1.read((0, 2, 2, 2)), b'\x00\x00\xff' * 2 * 2
    assert fbo1.read((2, 2, 2, 2)), b'\x00\x00\x00' * 2 * 2

    ctx.copy_framebuffer(fbo2, fbo1)

    assert fbo2.read((2, 2)), b'\xff\x00\x00' * 2 * 2
    assert fbo2.read((2, 0, 2, 2)), b'\x00\xff\x00' * 2 * 2
    assert fbo2.read((0, 2, 2, 2)), b'\x00\x00\xff' * 2 * 2
    assert fbo2.read((2, 2, 2, 2)), b'\x00\x00\x00' * 2 * 2