comparison 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
comparison
equal deleted inserted replaced
663:af9ab61aa87e 664:c33c8e156e3e
82 setMeshData[uint32](squaremesh, "index", iValues.toSeq) 82 setMeshData[uint32](squaremesh, "index", iValues.toSeq)
83 83
84 var myengine = initEngine("Squares") 84 var myengine = initEngine("Squares")
85 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) 85 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
86 86
87 var scene = newEntity("scene", newEntity("squares", squaremesh)) 87 var scene = newScene("scene", newEntity("scene", newEntity("squares", squaremesh)))
88 myengine.addScene(scene, vertexInput) 88 myengine.addScene(scene, vertexInput)
89 var time = initShaderGlobal("time", 0.0'f32) 89 scene.addShaderGlobal("time", 0.0'f32)
90 scene.components.add time
91 while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape): 90 while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape):
92 setValue[float32](time.value, get[float32](time.value) + 0.0005) 91 setShaderGlobal(scene, "time", getShaderGlobal[float32](scene, "time") + 0.0005'f)
93 myengine.renderScene(scene) 92 myengine.renderScene(scene)
94 93
95 myengine.destroy() 94 myengine.destroy()