Mercurial > games > semicongine
diff tests/test_vulkan_wrapper.nim @ 590:1edf3e16144e
add: input handling, small refactoring for renderer
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 18 Apr 2023 03:04:37 +0700 |
parents | b434feaf2b67 |
children | 11666d28e04d |
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim Mon Apr 17 18:02:19 2023 +0700 +++ b/tests/test_vulkan_wrapper.nim Tue Apr 18 03:04:37 2023 +0700 @@ -105,7 +105,7 @@ setInstanceData[Vec3f](c, "translate", @[newVec3f(-0.3, 0.1)]) result = newEntity("root", t, r, c) -when isMainModule: +proc main() = var engine = initEngine("Test") # INIT RENDERER: @@ -135,27 +135,32 @@ var surfaceFormat = engine.gpuDevice.physicalDevice.getSurfaceFormats().filterSurfaceFormat() renderPass = engine.gpuDevice.simpleForwardRenderPass(surfaceFormat.format, vertexCode, fragmentCode, 2) - renderer = engine.gpuDevice.initRenderer([renderPass]) + engine.setRenderer([renderPass]) - # INIT SCENE - + # INIT SCENES var scenes = [scene_simple(), scene_different_mesh_types(), scene_primitives()] var time = initShaderGlobal("time", 0.0'f32) for scene in scenes.mitems: scene.components.add time - renderer.setupDrawableBuffers(scene, vertexInput) + engine.addScene(scene, vertexInput) # MAINLOOP echo "Setup successfull, start rendering" for i in 0 ..< 3: for scene in scenes: for i in 0 ..< 1000: + engine.updateInputs() setValue[float32](time.value, get[float32](time.value) + 0.0005) - discard renderer.render(scene) - echo "Rendered ", renderer.framesRendered, " frames" + if not engine.running or engine.keyIsDown(Escape): + engine.destroy() + return + discard engine.renderScene(scene) + echo "Rendered ", engine.framesRendered, " frames" + echo "Processed ", engine.eventsProcessed, " events" # cleanup echo "Start cleanup" - checkVkResult engine.gpuDevice.vk.vkDeviceWaitIdle() - renderer.destroy() engine.destroy() + +when isMainModule: + main()