changeset 140:29f0109c5222

add: some helper functions
author Sam <sam@basx.dev>
date Sat, 22 Apr 2023 17:34:42 +0700
parents 34112bf5abf8
children 8bb27869b649
files src/semicongine/engine.nim src/semicongine/renderer.nim
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/engine.nim	Sat Apr 22 16:52:55 2023 +0700
+++ b/src/semicongine/engine.nim	Sat Apr 22 17:34:42 2023 +0700
@@ -90,6 +90,7 @@
   engine.renderer.setupDrawableBuffers(entity, vertexInput)
 
 proc renderScene*(engine: var Engine, entity: Entity) =
+  assert engine.renderer.valid
   if engine.running:
     engine.renderer.render(entity)
 
@@ -144,3 +145,4 @@
 func eventsProcessed*(engine: Engine): auto = engine.input.eventsProcessed
 func framesRendered*(engine: Engine): auto = engine.renderer.framesRendered
 func gpuDevice*(engine: Engine): Device = engine.device
+func getWindow*(engine: Engine): auto = engine.window
--- a/src/semicongine/renderer.nim	Sat Apr 22 16:52:55 2023 +0700
+++ b/src/semicongine/renderer.nim	Sat Apr 22 17:34:42 2023 +0700
@@ -181,6 +181,9 @@
 func framesRendered*(renderer: Renderer): uint64 =
   renderer.swapchain.framesRendered
 
+func valid*(renderer: Renderer): bool =
+  renderer.device.vk.valid
+
 proc destroy*(renderer: var Renderer) =
   for data in renderer.scenedata.mvalues:
     for buffer in data.vertexBuffers.mvalues: