comparison tests/test_vulkan_wrapper.nim @ 329:69e18f69713b

add: scene/shader compatability check, fix collision code to work with new APIs
author Sam <sam@basx.dev>
date Tue, 29 Aug 2023 00:01:13 +0700
parents 8d0ffcacc7e3
children 04531bec3583
comparison
equal deleted inserted replaced
328:8d0ffcacc7e3 329:69e18f69713b
11 wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT, 11 wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT,
12 ) 12 )
13 (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8]) 13 (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8])
14 mat = Material( 14 mat = Material(
15 name: "mat", 15 name: "mat",
16 materialType: "my_material", 16 materialType: "textures_material",
17 textures: { 17 textures: {
18 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ 18 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[
19 R, R, R, R, R, 19 R, R, R, R, R,
20 R, R, W, R, R, 20 R, R, W, R, R,
21 R, W, W, W, R, 21 R, W, W, W, R,
24 ]), sampler: sampler) 24 ]), sampler: sampler)
25 }.toTable 25 }.toTable
26 ) 26 )
27 mat2 = Material( 27 mat2 = Material(
28 name: "mat2", 28 name: "mat2",
29 materialType: "my_material", 29 materialType: "textures_material",
30 textures: { 30 textures: {
31 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ 31 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[
32 R, W, R, W, R, 32 R, W, R, W, R,
33 W, R, W, R, W, 33 W, R, W, R, W,
34 R, W, R, W, R, 34 R, W, R, W, R,
37 ]), sampler: sampler) 37 ]), sampler: sampler)
38 }.toTable 38 }.toTable
39 ) 39 )
40 mat3 = Material( 40 mat3 = Material(
41 name: "mat3", 41 name: "mat3",
42 materialType: "my_special_material", 42 materialType: "plain",
43 constants: { 43 constants: {
44 "color": toGPUValue(newVec4f(0, 1, 0, 1)) 44 "color": toGPUValue(newVec4f(0, 1, 0, 1))
45 }.toTable 45 }.toTable
46 ) 46 )
47 47
190 uniforms=[attr[Vec4f]("color")], 190 uniforms=[attr[Vec4f]("color")],
191 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color;""", 191 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color;""",
192 fragmentCode="color = outcolor;", 192 fragmentCode="color = outcolor;",
193 ) 193 )
194 engine.initRenderer({ 194 engine.initRenderer({
195 "my_material": shaderConfiguration1, 195 "textures_material": shaderConfiguration1,
196 "my_special_material": shaderConfiguration2, 196 "plain": shaderConfiguration2,
197 }.toTable) 197 }.toTable)
198 198
199 # INIT SCENES 199 # INIT SCENES
200 var scenes = [ 200 var scenes = [
201 Scene(name: "simple", meshes: scene_simple()), 201 Scene(name: "simple", meshes: scene_simple()),
203 Scene(name: "primitives", meshes: scene_primitives()), 203 Scene(name: "primitives", meshes: scene_primitives()),
204 Scene(name: "flag", meshes: scene_flag()), 204 Scene(name: "flag", meshes: scene_flag()),
205 Scene(name: "multimaterial", meshes: scene_multi_material()), 205 Scene(name: "multimaterial", meshes: scene_multi_material()),
206 ] 206 ]
207 207
208 scenes[4].addShaderGlobal("color", newVec4f(1, 0, 0, 1))
209 for scene in scenes.mitems: 208 for scene in scenes.mitems:
210 scene.addShaderGlobal("time", 0.0'f32) 209 scene.addShaderGlobal("time", 0.0'f32)
211 engine.addScene(scene) 210 engine.addScene(scene)
212 211
213 # MAINLOOP 212 # MAINLOOP