changeset 1364:8f774d9c2518 default tip

fix: change implementation to allow for easier reload of whole engine
author sam <sam@basx.dev>
date Tue, 05 Nov 2024 23:28:25 +0700
parents ce92db0b8f50
children
files semicongine/audio/mixer_module.nim semicongine/rendering.nim
diffstat 2 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/audio/mixer_module.nim	Tue Nov 05 23:02:32 2024 +0700
+++ b/semicongine/audio/mixer_module.nim	Tue Nov 05 23:28:25 2024 +0700
@@ -5,6 +5,7 @@
 import std/monotimes
 import std/strformat
 import std/tables
+import std/logging
 import std/times
 
 import ../core/globals
@@ -77,15 +78,13 @@
 # mixer.sounds[name] = LoadAudio(resource)
 
 proc addSound*(mixer: var Mixer, name: string, sound: SoundData) =
-  assert not (name in mixer.sounds)
-  mixer.sounds[name] = sound
-
-proc replaceSound*(mixer: var Mixer, name: string, sound: SoundData) =
-  assert (name in mixer.sounds)
+  if name in mixer.sounds:
+    warn "sound with name '", name, "' was already loaded, overwriting"
   mixer.sounds[name] = sound
 
 proc addTrack*(mixer: var Mixer, name: string, level: Level = 1'f) =
-  assert not (name in mixer.tracks)
+  if name in mixer.tracks:
+    warn "track with name '", name, "' was already loaded, overwriting"
   mixer.lock.withLock:
     mixer.tracks[name] = Track(level: level)
 
--- a/semicongine/rendering.nim	Tue Nov 05 23:02:32 2024 +0700
+++ b/semicongine/rendering.nim	Tue Nov 05 23:28:25 2024 +0700
@@ -382,8 +382,7 @@
   vulkan.swapchain = initSwapchain(renderPass, vSync = vSync)
 
 proc destroyVulkan*() =
-  if vulkan.swapchain != nil:
-    destroySwapchain(vulkan.swapchain)
+  clearSwapchain()
   vkDestroyDevice(vulkan.device, nil)
   vkDestroySurfaceKHR(vulkan.instance, vulkan.surface, nil)
   if vulkan.debugMessenger.Valid: