Mercurial > games > semicongine
diff tests/test_resources.nim @ 207:81fab407a479
add: some adjustment to the last refactoring :P
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 09 May 2023 01:18:01 +0700 |
parents | |
children | b5d9410a8184 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_resources.nim Tue May 09 01:18:01 2023 +0700 @@ -0,0 +1,32 @@ +import std/times + +import semicongine + +proc main() = + var scene = newScene("main", root=newEntity("rect", rect())) + var engine = initEngine("Test materials") + const + vertexInput = @[ + attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), + ] + fragOutput = @[attr[Vec4f]("color")] + vertexCode = compileGlslShader( + stage=VK_SHADER_STAGE_VERTEX_BIT, + inputs=vertexInput, + main="""gl_Position = vec4(position, 1.0);""" + ) + fragmentCode = compileGlslShader( + stage=VK_SHADER_STAGE_FRAGMENT_BIT, + outputs=fragOutput, + main="""color = vec4(1, 0, 0, 1);""" + ) + engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) + engine.addScene(scene, vertexInput) + var t = cpuTime() + while engine.updateInputs() == Running and not engine.keyIsDown(Escape): + engine.renderScene(scene) + engine.destroy() + + +when isMainModule: + main()