Mercurial > games > semicongine
comparison tests/test_materials.nim @ 714:5f7ec8d1bd33
fix: API changes
author | sam <sam@basx.dev> |
---|---|
date | Wed, 24 May 2023 01:31:21 +0700 |
parents | 37ef17c96bdb |
children | bfcb41211c5b |
comparison
equal
deleted
inserted
replaced
713:cdb3ff9b0047 | 714:5f7ec8d1bd33 |
---|---|
12 WT, WT, WT, WT, WT, WT, WT, | 12 WT, WT, WT, WT, WT, WT, WT, |
13 PT, PT, PT, PT, PT, PT, PT, | 13 PT, PT, PT, PT, PT, PT, PT, |
14 WT, WT, WT, WT, WT, WT, WT, | 14 WT, WT, WT, WT, WT, WT, WT, |
15 RT, RT, RT, RT, RT, RT, RT, | 15 RT, RT, RT, RT, RT, RT, RT, |
16 ]) | 16 ]) |
17 let | |
17 # image from file | 18 # image from file |
18 t2 = loadImage("flag.png") | 19 t2 = loadImage("flag.png") |
20 | |
19 var sampler = DefaultSampler() | 21 var sampler = DefaultSampler() |
20 sampler.magnification = VK_FILTER_NEAREST | 22 sampler.magnification = VK_FILTER_NEAREST |
21 sampler.minification = VK_FILTER_NEAREST | 23 sampler.minification = VK_FILTER_NEAREST |
22 scene.addTextures("my_texture", @[Texture(image: t1, sampler: sampler), Texture(image: t2, sampler: sampler)]) | 24 scene.addTextures("my_texture", @[Texture(image: t1, sampler: sampler), Texture(image: t2, sampler: sampler)]) |
23 scene.addShaderGlobalArray("test2", @[0'f32, 0'f32]) | 25 scene.addShaderGlobalArray("test2", @[0'f32, 0'f32]) |
24 | 26 |
25 var engine = initEngine("Test materials") | 27 var engine = initEngine("Test materials") |
28 | |
26 const | 29 const |
27 vertexInput = @[ | 30 vertexInput = @[ |
28 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), | 31 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), |
29 attr[Vec2f]("uv", memoryPerformanceHint=PreferFastRead), | 32 attr[Vec2f]("uv", memoryPerformanceHint=PreferFastRead), |
30 ] | 33 ] |
50 float d = sin(Uniforms.test2[0]) * 0.5 + 0.5; | 53 float d = sin(Uniforms.test2[0]) * 0.5 + 0.5; |
51 color = texture(my_texture[0], uvout) * (1 - d) + texture(my_texture[1], uvout) * d; | 54 color = texture(my_texture[0], uvout) * (1 - d) + texture(my_texture[1], uvout) * d; |
52 """ | 55 """ |
53 ) | 56 ) |
54 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) | 57 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) |
55 engine.addScene(scene, vertexInput) | 58 engine.addScene(scene, vertexInput, samplers) |
56 var t = cpuTime() | 59 var t = cpuTime() |
57 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): | 60 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): |
58 var d = float32(cpuTime() - t) | 61 var d = float32(cpuTime() - t) |
59 setShaderGlobalArray(scene, "test2", @[d, d * 2]) | 62 setShaderGlobalArray(scene, "test2", @[d, d * 2]) |
60 engine.renderScene(scene) | 63 engine.renderScene(scene) |