Mercurial > games > semicongine
annotate tests/test_resources.nim @ 211:744285b47a4d
did: refactor image handling
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 09 May 2023 19:52:57 +0700 |
parents | 81fab407a479 |
children | b5d9410a8184 |
rev | line source |
---|---|
207
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
1 import std/times |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
2 |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
3 import semicongine |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
4 |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
5 proc main() = |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
6 var scene = newScene("main", root=newEntity("rect", rect())) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
7 var engine = initEngine("Test materials") |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
8 const |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
9 vertexInput = @[ |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
10 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
11 ] |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
12 fragOutput = @[attr[Vec4f]("color")] |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
13 vertexCode = compileGlslShader( |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
14 stage=VK_SHADER_STAGE_VERTEX_BIT, |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
15 inputs=vertexInput, |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
16 main="""gl_Position = vec4(position, 1.0);""" |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
17 ) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
18 fragmentCode = compileGlslShader( |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
19 stage=VK_SHADER_STAGE_FRAGMENT_BIT, |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
20 outputs=fragOutput, |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
21 main="""color = vec4(1, 0, 0, 1);""" |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
22 ) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
23 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
24 engine.addScene(scene, vertexInput) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
25 var t = cpuTime() |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
26 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
27 engine.renderScene(scene) |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
28 engine.destroy() |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
29 |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
30 |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
31 when isMainModule: |
81fab407a479
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff
changeset
|
32 main() |