Mercurial > games > semicongine
comparison examples/E02_squares.nim @ 203:84fd522fdf3f
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 | 25d97fa0ad5c |
children | 6e2017cb8b8b |
comparison
equal
deleted
inserted
replaced
202:9bb3fdbecc52 | 203:84fd522fdf3f |
---|---|
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() |