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
|
import moderngl
def test_create(ctx):
sampler = ctx.sampler()
sampler.use(location=0)
sampler.clear(location=0)
def test_defaults(ctx):
sampler = ctx.sampler()
assert sampler.anisotropy <= 1.0
assert sampler.repeat_x is True
assert sampler.repeat_y is True
assert sampler.repeat_z is True
assert sampler.filter == (moderngl.LINEAR, moderngl.LINEAR)
assert sampler.compare_func == '?'
assert sampler.border_color == (0.0, 0.0, 0.0, 0.0)
assert sampler.min_lod == -1000.0
assert sampler.max_lod == 1000.0
def test_prop_changes(ctx):
sampler = ctx.sampler()
# Change values
sampler.anisotropy = ctx.max_anisotropy
sampler.filter = (moderngl.NEAREST_MIPMAP_NEAREST, moderngl.NEAREST)
sampler.compare_func = "<="
assert sampler.anisotropy == ctx.max_anisotropy
assert sampler.filter == (moderngl.NEAREST_MIPMAP_NEAREST, moderngl.NEAREST)
assert sampler.compare_func == "<="
# Ensure repeat parameters are set correctly
sampler.repeat_x = False
assert (sampler.repeat_x, sampler.repeat_y, sampler.repeat_z) == (False, True, True)
sampler.repeat_y = False
assert (sampler.repeat_x, sampler.repeat_y, sampler.repeat_z) == (False, False, True)
sampler.repeat_z = False
assert (sampler.repeat_x, sampler.repeat_y, sampler.repeat_z) == (False, False, False)
def test_border_color(ctx):
sampler = ctx.sampler()
# Ensure border color values are set correctly
colors = [
(1.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0),
(0.0, 0.0, 0.0, 1.0),
]
for color in colors:
sampler.border_color = color
assert sampler.border_color == color
def test_lod(ctx):
sampler = ctx.sampler()
sampler.min_lod = 0.0
assert sampler.min_lod == 0.0
sampler.max_lod = 500.0
assert sampler.max_lod == 500.0
def test_clear_samplers(ctx):
ctx.clear_samplers(start=0, end=5)
ctx.clear_samplers(start=5, end=10)
ctx.clear_samplers(start=10, end=100)
def test_sampler_labels(ctx):
sampler = ctx.sampler()
sampler.label = "sampler of excellence"
assert sampler.label == "sampler of excellence"
|