Mercurial > games > semicongine
comparison tests/test_resources.nim @ 213:b5d9410a8184
add: resource packaging and loading for different resource types, simplify build commands, update readme
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 10 May 2023 22:36:59 +0700 |
parents | 81fab407a479 |
children | 5f6d3511ef79 |
comparison
equal
deleted
inserted
replaced
212:77755701bf49 | 213:b5d9410a8184 |
---|---|
1 import std/times | 1 import std/times |
2 | 2 |
3 import semicongine | 3 import semicongine |
4 | 4 |
5 proc main() = | 5 proc main() = |
6 var scene = newScene("main", root=newEntity("rect", rect())) | 6 echo "Mods available: ", modList() |
7 var engine = initEngine("Test materials") | 7 for modName in modList(): |
8 const | 8 echo modName, ":" |
9 vertexInput = @[ | 9 selectedMod = modName |
10 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), | 10 for i in walkResources(): |
11 ] | 11 echo " ", i, ": ", loadResource(i)[] |
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 | 12 |
31 when isMainModule: | 13 when isMainModule: |
32 main() | 14 main() |