changeset 1135:74957cbf589b

fix: update tests according to some API renaming
author sam <sam@basx.dev>
date Mon, 03 Jun 2024 16:05:17 +0700
parents 055eb17ce31e
children 71315636ba82
files semicongine/core/imagetypes.nim tests/test_audio.nim tests/test_collision.nim tests/test_font.nim tests/test_materials.nim tests/test_mesh.nim tests/test_panel.nim tests/test_vulkan_wrapper.nim
diffstat 8 files changed, 77 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/core/imagetypes.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/semicongine/core/imagetypes.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -1,4 +1,3 @@
-import std/math
 import std/strformat
 
 import ./vulkanapi
--- a/tests/test_audio.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_audio.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -6,23 +6,23 @@
 
 
 proc test1() =
-  mixer[].addSound("test1", newSound(sineSoundData(1000, 2, 44100)))
-  mixer[].addSound("test2", newSound(sineSoundData(500, 2, 44100)))
+  mixer[].AddSound("test1", newSound(sineSoundData(1000, 2, 44100)))
+  mixer[].AddSound("test2", newSound(sineSoundData(500, 2, 44100)))
 
 
-  let s1 = mixer[].play("test1", loop = true)
-  let s2 = mixer[].play("test2", loop = true)
+  let s1 = mixer[].Play("test1", loop = true)
+  let s2 = mixer[].Play("test2", loop = true)
 
   let t0 = now()
-  mixer[].setLevel(0.5)
+  mixer[].SetLevel(0.5)
   while true:
     let runtime = (now() - t0).inMilliseconds()
     if runtime > 1500:
-      mixer[].setLevel(0.2)
+      mixer[].SetLevel(0.2)
     if runtime > 3000:
-      mixer[].stop(s2)
+      mixer[].Stop(s2)
     if runtime > 6000:
-      mixer[].stop("")
+      mixer[].Stop("")
     if runtime > 8000:
       break
 
@@ -55,34 +55,34 @@
       f, c, f, f,
     )
 
-  mixer[].addSound("frerejaques", newSound(frerejaquesData))
-  discard mixer[].play("frerejaques")
+  mixer[].AddSound("frerejaques", newSound(frerejaquesData))
+  discard mixer[].Play("frerejaques")
 
-  while mixer[].isPlaying():
+  while mixer[].IsPlaying():
     sleep(1)
 
 proc test3() =
-  mixer[].addSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg"))
-  mixer[].addSound("ping", newSound(sineSoundData(500, 0.05, 44100)))
-  mixer[].addTrack("effects")
-  discard mixer[].play("toccata et fugue")
+  mixer[].AddSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg"))
+  mixer[].AddSound("ping", newSound(sineSoundData(500, 0.05, 44100)))
+  mixer[].AddTrack("effects")
+  discard mixer[].Play("toccata et fugue")
 
 
 when isMainModule:
-  startMixerThread()
+  StartMixerThread()
   test1()
-  mixer[].stop()
+  mixer[].Stop()
   test2()
-  mixer[].stop()
+  mixer[].Stop()
   test3()
 
-  while mixer[].isPlaying():
-    discard mixer[].play("ping", track = "effects", stopOtherSounds = true, level = 0.5)
+  while mixer[].IsPlaying():
+    discard mixer[].Play("ping", track = "effects", stopOtherSounds = true, level = 0.5)
     # on windows we re-open stdin and this will not work
     when defined(linux):
       echo "Press q and enter to exit"
       if stdin.readLine() == "q":
-        mixer[].stop()
+        mixer[].Stop()
     elif defined(windows):
       sleep(5)
-      mixer[].stop()
+      mixer[].Stop()
--- a/tests/test_collision.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_collision.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -33,21 +33,21 @@
   engine.initRenderer({VERTEX_COLORED_MATERIAL: shaderConfiguration})
   engine.loadScene(scene)
 
-  while engine.updateInputs() and not keyIsDown(Escape):
-    if windowWasResized():
-      var winSize = engine.getWindow().size
+  while engine.UpdateInputs() and not KeyIsDown(Escape):
+    if WindowWasResized():
+      var winSize = engine.GetWindow().size
       scene.setShaderGlobal("perspective", orthoWindowAspect(winSize[0] / winSize[1]))
-    if keyIsDown(A): scene.meshes[0].transform = scene.meshes[0].transform * translate(-0.001, 0, 0)
-    if keyIsDown(D): scene.meshes[0].transform = scene.meshes[0].transform * translate(0.001, 0, 0)
-    if keyIsDown(W): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, -0.001, 0)
-    if keyIsDown(S): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, 0.001, 0)
-    if keyIsDown(Q): scene.meshes[0].transform = scene.meshes[0].transform * rotate(-0.001, Z)
-    if keyIsDown(Key.E): scene.meshes[0].transform = scene.meshes[0].transform * rotate(0.001, Z)
+    if KeyIsDown(A): scene.meshes[0].transform = scene.meshes[0].transform * translate(-0.001, 0, 0)
+    if KeyIsDown(D): scene.meshes[0].transform = scene.meshes[0].transform * translate(0.001, 0, 0)
+    if KeyIsDown(W): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, -0.001, 0)
+    if KeyIsDown(S): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, 0.001, 0)
+    if KeyIsDown(Q): scene.meshes[0].transform = scene.meshes[0].transform * rotate(-0.001, Z)
+    if KeyIsDown(Key.E): scene.meshes[0].transform = scene.meshes[0].transform * rotate(0.001, Z)
 
-    if keyIsDown(Key.Z): scene.meshes[1].transform = scene.meshes[1].transform * rotate(-0.001, Z)
-    if keyIsDown(Key.X): scene.meshes[1].transform = scene.meshes[1].transform * rotate(0.001, Z)
-    if keyIsDown(Key.C): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, -0.001, 0)
-    if keyIsDown(Key.V): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, 0.001, 0)
+    if KeyIsDown(Key.Z): scene.meshes[1].transform = scene.meshes[1].transform * rotate(-0.001, Z)
+    if KeyIsDown(Key.X): scene.meshes[1].transform = scene.meshes[1].transform * rotate(0.001, Z)
+    if KeyIsDown(Key.C): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, -0.001, 0)
+    if KeyIsDown(Key.V): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, 0.001, 0)
     let hitbox = Collider(theType: Box, transform: scene.meshes[0].transform * translate(-0.5, -0.5))
     let hitsphere = Collider(theType: Sphere, transform: scene.meshes[2].transform, radius: 0.5)
     echo intersects(hitbox, hitsphere)
--- a/tests/test_font.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_font.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -28,45 +28,45 @@
   scene.add main_text
   scene.add help_text
   engine.loadScene(scene)
-  mixer[].loadSound("key", "key.ogg")
-  mixer[].setLevel(0.5)
+  mixer[].LoadSound("key", "key.ogg")
+  mixer[].SetLevel(0.5)
 
-  while engine.updateInputs() and not keyIsDown(Escape):
+  while engine.UpdateInputs() and not KeyIsDown(Escape):
     var t = cpuTime()
     main_text.color = newVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1)
-    if windowWasResized():
-      var winSize = engine.getWindow().size
+    if WindowWasResized():
+      var winSize = engine.GetWindow().size
 
     # add character
     if main_text.text.len < main_text.maxLen - 1:
       for c in [Key.A, Key.B, Key.C, Key.D, Key.E, Key.F, Key.G, Key.H, Key.I,
           Key.J, Key.K, Key.L, Key.M, Key.N, Key.O, Key.P, Key.Q, Key.R, Key.S,
           Key.T, Key.U, Key.V, Key.W, Key.X, Key.Y, Key.Z]:
-        if keyWasPressed(c):
-          discard mixer[].play("key")
-          if keyIsDown(ShiftL) or keyIsDown(ShiftR):
+        if KeyWasPressed(c):
+          discard mixer[].Play("key")
+          if KeyIsDown(ShiftL) or KeyIsDown(ShiftR):
             main_text.text = main_text.text & ($c).toRunes
           else:
             main_text.text = main_text.text & ($c).toRunes[0].toLower()
-      if keyWasPressed(Enter):
-        discard mixer[].play("key")
+      if KeyWasPressed(Enter):
+        discard mixer[].Play("key")
         main_text.text = main_text.text & Rune('\n')
-      if keyWasPressed(Space):
-        discard mixer[].play("key")
+      if KeyWasPressed(Space):
+        discard mixer[].Play("key")
         main_text.text = main_text.text & Rune(' ')
 
     # remove character
-    if keyWasPressed(Backspace) and main_text.text.len > 0:
-      discard mixer[].play("key")
+    if KeyWasPressed(Backspace) and main_text.text.len > 0:
+      discard mixer[].Play("key")
       main_text.text = main_text.text[0 ..< ^1]
 
     # alignemtn with F-keys
-    if keyWasPressed(F1): main_text.horizontalAlignment = Left
-    elif keyWasPressed(F2): main_text.horizontalAlignment = Center
-    elif keyWasPressed(F3): main_text.horizontalAlignment = Right
-    elif keyWasPressed(F4): main_text.verticalAlignment = Top
-    elif keyWasPressed(F5): main_text.verticalAlignment = Center
-    elif keyWasPressed(F6): main_text.verticalAlignment = Bottom
+    if KeyWasPressed(F1): main_text.horizontalAlignment = Left
+    elif KeyWasPressed(F2): main_text.horizontalAlignment = Center
+    elif KeyWasPressed(F3): main_text.horizontalAlignment = Right
+    elif KeyWasPressed(F4): main_text.verticalAlignment = Top
+    elif KeyWasPressed(F5): main_text.verticalAlignment = Center
+    elif KeyWasPressed(F6): main_text.verticalAlignment = Bottom
 
     origin.refresh()
     main_text.text = main_text.text & Rune('_')
--- a/tests/test_materials.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_materials.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -68,7 +68,7 @@
   })
   engine.loadScene(scene)
   var t = cpuTime()
-  while engine.updateInputs() and not keyIsDown(Escape):
+  while engine.UpdateInputs() and not KeyIsDown(Escape):
     var d = float32(cpuTime() - t)
     setShaderGlobalArray(scene, "test2", @[newVec4f(d), newVec4f(d * 2)])
     engine.renderScene(scene)
--- a/tests/test_mesh.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_mesh.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -59,29 +59,29 @@
     azimut = 0'f32
     currentScene = 0
 
-  while engine.updateInputs() and not keyIsDown(Escape):
-    if keyWasPressed(`1`):
+  while engine.UpdateInputs() and not KeyIsDown(Escape):
+    if KeyWasPressed(`1`):
       currentScene = 0
-    elif keyWasPressed(`2`):
+    elif KeyWasPressed(`2`):
       currentScene = 1
-    elif keyWasPressed(`3`):
+    elif KeyWasPressed(`3`):
       currentScene = 2
-    elif keyWasPressed(`4`):
+    elif KeyWasPressed(`4`):
       currentScene = 3
-    elif keyWasPressed(`5`):
+    elif KeyWasPressed(`5`):
       currentScene = 4
-    elif keyWasPressed(`6`):
+    elif KeyWasPressed(`6`):
       currentScene = 5
 
-    if keyWasPressed(NumberRowExtra3):
+    if KeyWasPressed(NumberRowExtra3):
       size = 0.3'f32
       elevation = 0'f32
       azimut = 0'f32
 
-    let ratio = engine.getWindow().size[0] / engine.getWindow().size[1]
-    size *= 1'f32 + mouseWheel() * 0.05
-    azimut += mouseMove().x / 180'f32
-    elevation -= mouseMove().y / 180'f32
+    let ratio = engine.GetWindow().size[0] / engine.GetWindow().size[1]
+    size *= 1'f32 + MouseWheel() * 0.05
+    azimut += MouseMove().x / 180'f32
+    elevation -= MouseMove().y / 180'f32
     scenes[currentScene].setShaderGlobal("projection", perspective(PI / 2, ratio, -0.5, 1))
     scenes[currentScene].setShaderGlobal(
       "view",
--- a/tests/test_panel.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_panel.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -64,27 +64,27 @@
   scene.add origin
   engine.loadScene(scene)
 
-  while engine.updateInputs() and not keyIsDown(Escape):
-    if keyWasPressed(F1):
+  while engine.UpdateInputs() and not KeyIsDown(Escape):
+    if KeyWasPressed(F1):
       button.horizontalAlignment = Left
       counterText.horizontalAlignment = Left
-    elif keyWasPressed(F2):
+    elif KeyWasPressed(F2):
       button.horizontalAlignment = Center
       counterText.horizontalAlignment = Center
-    elif keyWasPressed(F3):
+    elif KeyWasPressed(F3):
       button.horizontalAlignment = Right
       counterText.horizontalAlignment = Right
-    elif keyWasPressed(F4):
+    elif KeyWasPressed(F4):
       button.verticalAlignment = Top
       counterText.verticalAlignment = Top
-    elif keyWasPressed(F5):
+    elif KeyWasPressed(F5):
       button.verticalAlignment = Center
       counterText.verticalAlignment = Center
-    elif keyWasPressed(F6):
+    elif KeyWasPressed(F6):
       button.verticalAlignment = Bottom
       counterText.verticalAlignment = Bottom
 
-    engine.processEvents(button)
+    engine.ProcessEvents(button)
 
     button.refresh()
     counterText.refresh()
--- a/tests/test_vulkan_wrapper.nim	Mon Jun 03 15:53:30 2024 +0700
+++ b/tests/test_vulkan_wrapper.nim	Mon Jun 03 16:05:17 2024 +0700
@@ -239,7 +239,7 @@
     for scene in scenes.mitems:
       echo "rendering scene ", scene.name
       for i in 0 ..< 1000:
-        if not engine.updateInputs() or keyIsDown(Escape):
+        if not engine.UpdateInputs() or KeyIsDown(Escape):
           engine.destroy()
           return
         engine.renderScene(scene)