File: test_renderbuffer.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 (54 lines) | stat: -rw-r--r-- 1,393 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
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
import pytest


def test_renderbuffer(ctx):
    rbo = ctx.renderbuffer((4, 8))
    assert rbo.size == (4, 8)
    assert rbo.width == 4
    assert rbo.height == 8
    assert rbo.samples == 0
    assert rbo.depth is False
    assert rbo.components == 4
    assert rbo.dtype == 'f1'
    assert rbo == rbo


def test_multisample_renderbuffer(ctx):
    if ctx.max_samples < 2:
        pytest.skip('multisampling is not supported')

    rbo = ctx.renderbuffer((4, 4), samples=2)
    assert rbo.size == (4, 4)
    assert rbo.samples == 2
    assert rbo.depth is False


def test_depth_renderbuffer(ctx):
    rbo = ctx.depth_renderbuffer((4, 4))
    assert rbo.size == (4, 4)
    assert rbo.samples == 0
    assert rbo.depth is True


def test_multisample_depth_renderbuffer(ctx):
    if ctx.max_samples < 2:
        pytest.skip('multisampling is not supported')

    rbo = ctx.depth_renderbuffer((4, 4), samples=2)
    assert rbo.size == (4, 4)
    assert rbo.samples == 2
    assert rbo.depth is True


def test_renderbuffer_invalid_samples(ctx):
    if ctx.max_samples < 2:
        pytest.skip('multisampling is not supported')

    with pytest.raises(Exception, match='samples is invalid'):
        ctx.renderbuffer((4, 4), samples=3)


def test_renderbuffer_labels(ctx):
    rbo = ctx.renderbuffer((4, 8))
    rbo.label = "best renderbuffer ever"
    assert rbo.label == "best renderbuffer ever"