annotate tests/test_panel.nim @ 892:f2d7529b49ca

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