diff examples/E02_squares.nim @ 664:c33c8e156e3e

did: update examples to use new API for scene + scene globals
author Sam <sam@basx.dev>
date Mon, 08 May 2023 21:21:49 +0700
parents 3f13de7d8ec4
children e85f54b88afb
line wrap: on
line diff
--- a/examples/E02_squares.nim	Mon May 08 00:48:11 2023 +0700
+++ b/examples/E02_squares.nim	Mon May 08 21:21:49 2023 +0700
@@ -84,12 +84,11 @@
   var myengine = initEngine("Squares")
   myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
 
-  var scene = newEntity("scene", newEntity("squares", squaremesh))
+  var scene = newScene("scene", newEntity("scene", newEntity("squares", squaremesh)))
   myengine.addScene(scene, vertexInput)
-  var time = initShaderGlobal("time", 0.0'f32)
-  scene.components.add time
+  scene.addShaderGlobal("time", 0.0'f32)
   while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape):
-    setValue[float32](time.value, get[float32](time.value) + 0.0005)
+    setShaderGlobal(scene, "time", getShaderGlobal[float32](scene, "time") + 0.0005'f)
     myengine.renderScene(scene)
 
   myengine.destroy()