comparison 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
comparison
equal deleted inserted replaced
206:7f921d7d0a2b 207:81fab407a479
1 import std/times
2
3 import semicongine
4
5 proc main() =
6 var scene = newScene("main", root=newEntity("rect", rect()))
7 var engine = initEngine("Test materials")
8 const
9 vertexInput = @[
10 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead),
11 ]
12 fragOutput = @[attr[Vec4f]("color")]
13 vertexCode = compileGlslShader(
14 stage=VK_SHADER_STAGE_VERTEX_BIT,
15 inputs=vertexInput,
16 main="""gl_Position = vec4(position, 1.0);"""
17 )
18 fragmentCode = compileGlslShader(
19 stage=VK_SHADER_STAGE_FRAGMENT_BIT,
20 outputs=fragOutput,
21 main="""color = vec4(1, 0, 0, 1);"""
22 )
23 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
24 engine.addScene(scene, vertexInput)
25 var t = cpuTime()
26 while engine.updateInputs() == Running and not engine.keyIsDown(Escape):
27 engine.renderScene(scene)
28 engine.destroy()
29
30
31 when isMainModule:
32 main()