comparison tests/test_vulkan_wrapper.nim @ 792:d65b62812d34

did: undid using meshes as values, ref is much better, fix a few things, fix a few huge performance issues
author Sam <sam@basx.dev>
date Sun, 03 Sep 2023 17:34:29 +0700
parents 43432dad4797
children 2533f524bdb6
comparison
equal deleted inserted replaced
791:43432dad4797 792:d65b62812d34
166 ], 166 ],
167 intermediates=[ 167 intermediates=[
168 attr[Vec4f]("outcolor"), 168 attr[Vec4f]("outcolor"),
169 ], 169 ],
170 outputs=[attr[Vec4f]("color")], 170 outputs=[attr[Vec4f]("color")],
171 uniforms=[attr[float32]("time")],
172 samplers=[ 171 samplers=[
173 attr[Sampler2DType]("my_little_texture") 172 attr[Sampler2DType]("my_little_texture")
174 ], 173 ],
175 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = color;""", 174 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = color;""",
176 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;", 175 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;",
200 Scene(name: "flag", meshes: scene_flag()), 199 Scene(name: "flag", meshes: scene_flag()),
201 Scene(name: "multimaterial", meshes: scene_multi_material()), 200 Scene(name: "multimaterial", meshes: scene_multi_material()),
202 ] 201 ]
203 202
204 for scene in scenes.mitems: 203 for scene in scenes.mitems:
205 scene.addShaderGlobal("time", 0.0'f32)
206 engine.addScene(scene) 204 engine.addScene(scene)
207 205
208 # MAINLOOP 206 # MAINLOOP
209 echo "Setup successfull, start rendering" 207 echo "Setup successfull, start rendering"
210 for i in 0 ..< 3: 208 for i in 0 ..< 3:
212 echo "rendering scene ", scene.name 210 echo "rendering scene ", scene.name
213 for i in 0 ..< 1000: 211 for i in 0 ..< 1000:
214 if engine.updateInputs() != Running or engine.keyIsDown(Escape): 212 if engine.updateInputs() != Running or engine.keyIsDown(Escape):
215 engine.destroy() 213 engine.destroy()
216 return 214 return
217 setShaderGlobal(scene, "time", getShaderGlobal[float32](scene, "time") + 0.0005'f)
218 engine.renderScene(scene) 215 engine.renderScene(scene)
219 echo "Rendered ", engine.framesRendered, " frames" 216 echo "Rendered ", engine.framesRendered, " frames"
220 echo "Processed ", engine.eventsProcessed, " events" 217 echo "Processed ", engine.eventsProcessed, " events"
221 218
222 # cleanup 219 # cleanup