File: test_sampler_uniforms.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 (39 lines) | stat: -rw-r--r-- 920 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

def test_sampler_2D_get_setter(ctx):
    prog = ctx.program(
        vertex_shader='''
            #version 330
            uniform sampler2D Texture2D;
            void main() {
                gl_Position = texture(Texture2D, vec2(0.0, 0.0));
            }
        '''
    )

    sampler_uniform = prog['Texture2D']

    sampler_uniform.value = 3
    assert sampler_uniform.value == 3

    sampler_uniform.value = 1
    assert sampler_uniform.value == 1


def test_sampler_3D_get_setter(ctx):
    prog = ctx.program(
        vertex_shader='''
            #version 330
            uniform sampler3D Texture3D;
            void main() {
                gl_Position = texture(Texture3D, vec3(0.0, 0.0, 0.0));
            }
        '''
    )

    sampler_uniform = prog['Texture3D']

    sampler_uniform.value = 3
    assert sampler_uniform.value == 3

    sampler_uniform.value = 1
    assert sampler_uniform.value == 1