Mercurial > games > semicongine
comparison examples/E03_hello_cube.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 |
---|---|
74 uniforms=uniforms, | 74 uniforms=uniforms, |
75 outputs=fragOutput, | 75 outputs=fragOutput, |
76 main="color = vec4(outcolor, 1);" | 76 main="color = vec4(outcolor, 1);" |
77 ) | 77 ) |
78 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) | 78 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) |
79 var | 79 var cube = newScene("scene", newEntity("cube", newMesh(positions=cube_pos, indices=tris, colors=cube_color))) |
80 projection = initShaderGlobal("projection", Unit4f32) | 80 cube.addShaderGlobal("projection", Unit4f32) |
81 view = initShaderGlobal("view", Unit4f32) | 81 cube.addShaderGlobal("view", Unit4f32) |
82 model = initShaderGlobal("model", Unit4f32) | 82 cube.addShaderGlobal("model", Unit4f32) |
83 cube = newEntity("cube", newMesh(positions=cube_pos, indices=tris, colors=cube_color)) | |
84 cube.components.add projection | |
85 cube.components.add view | |
86 cube.components.add model | |
87 myengine.addScene(cube, vertexInput) | 83 myengine.addScene(cube, vertexInput) |
88 | 84 |
89 var t: float32 = cpuTime() | 85 var t: float32 = cpuTime() |
90 while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape): | 86 while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape): |
91 setValue[Mat4](model.value, translate3d(0'f32, 0'f32, 10'f32) * rotate3d(t, Yf32)) | 87 setShaderGlobal(cube, "model", translate3d(0'f32, 0'f32, 10'f32) * rotate3d(t, Yf32)) |
92 setValue[Mat4]( | 88 setShaderGlobal(cube, "projection", |
93 projection.value, | |
94 perspective( | 89 perspective( |
95 float32(PI / 4), | 90 float32(PI / 4), |
96 float32(myengine.getWindow().size[0]) / float32(myengine.getWindow().size[0]), | 91 float32(myengine.getWindow().size[0]) / float32(myengine.getWindow().size[0]), |
97 0.1'f32, | 92 0.1'f32, |
98 100'f32 | 93 100'f32 |