Mercurial > games > semicongine
diff tests/test_rendering.nim @ 1233:1cf698973dca
did: cleanup tests and old platform layer files
author | sam <sam@basx.dev> |
---|---|
date | Fri, 19 Jul 2024 21:25:42 +0700 |
parents | 32a977c71ba5 |
children | c70fee6568f6 |
line wrap: on
line diff
--- a/tests/test_rendering.nim Fri Jul 19 20:00:15 2024 +0700 +++ b/tests/test_rendering.nim Fri Jul 19 21:25:42 2024 +0700 @@ -1,3 +1,4 @@ +import std/os import std/sequtils import std/monotimes import std/times @@ -416,13 +417,13 @@ var t = tStart while UpdateInputs() and c < nFrames: - let t = getMonoTime() - tStart + let tStartLoop = getMonoTime() - tStart uniforms1.data.data.data.mvp = ( Perspective(-PI / 2, GetAspectRatio(swapchain), 0.01, 100) * Translate(0, 0, 2) * Rotate(PI / 4, X) * - Rotate(PI * 0.5 * (t.inMicroseconds() / 1_000_000), Y) + Rotate(PI * 0.1 * (tStartLoop.inMicroseconds() / 1_000_000), Y) ) UpdateGPUBuffer(uniforms1.data.data, flush = true) WithNextFrame(swapchain, framebuffer, commandbuffer): @@ -431,6 +432,13 @@ WithBind(commandbuffer, (uniforms1, ), pipeline, swapchain.currentFiF): Render(commandbuffer = commandbuffer, pipeline = pipeline, mesh = mesh) Render(commandbuffer = commandbuffer, pipeline = pipeline, mesh = floor) + + let tEndLoop = getMonoTime() - tStart + let looptime = tEndLoop - tStartLoop + let waitTime = 16_666 - looptime.inMicroseconds + if waitTime > 0: + echo "sleep ", waitTime / 1000 + sleep((waitTime / 1000).int) inc c # cleanup