annotate tests/test_panel.nim @ 431:e13b75bff00c

intermediate commit :P
author Sam <sam@basx.dev>
date Fri, 09 Feb 2024 20:02:55 +0700
parents c5999345f42c
children 08b8facaf3b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
1 import std/unicode
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
2
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
3 import semicongine
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
4
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
5
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
6 proc main() =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
7 # setup engine
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
8 var engine = initEngine("Test panels")
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
9 engine.initRenderer([])
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
10
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
11 # build scene
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
12 var scene = Scene(name: "main")
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
13 var panel = Panel(position: newVec2f(0, 0), size: newVec2f(0.1, 0.1))
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
14
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
15 scene.add panel
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
16 engine.loadScene(scene)
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
17
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
18 while engine.updateInputs() == Running and not engine.keyIsDown(Escape):
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
19 if engine.windowWasResized():
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
20 var winSize = engine.getWindow().size
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
21 panel.aspect_ratio = winSize[0] / winSize[1]
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
22
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
23 engine.renderScene(scene)
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
24 engine.destroy()
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
25
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
26
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
27 when isMainModule:
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
28 main()