Mercurial > games > semicongine
comparison tests/test_font.nim @ 832:388c4b35a6e3
fix: tests, test_materials and test_mesh still needs to be done
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 22 Nov 2023 23:24:47 +0700 |
parents | 7a13941ba204 |
children | e50c57423567 |
comparison
equal
deleted
inserted
replaced
831:902735626b66 | 832:388c4b35a6e3 |
---|---|
1 import std/unicode | 1 import std/unicode |
2 | 2 |
3 import semicongine | 3 import semicongine |
4 | 4 |
5 proc main() = | 5 proc main() = |
6 # setup engine | |
7 var engine = initEngine("Test fonts") | |
8 engine.initRenderer([]) | |
9 | |
10 # build scene | |
11 var scene = Scene(name: "main") | |
6 var font = loadFont("DejaVuSans.ttf", color=newVec4f(1, 0.5, 0.5, 1), resolution=20) | 12 var font = loadFont("DejaVuSans.ttf", color=newVec4f(1, 0.5, 0.5, 1), resolution=20) |
7 | |
8 var textbox = initTextbox(32, font, "") | 13 var textbox = initTextbox(32, font, "") |
9 var scene = Scene(name: "main") | |
10 scene.add textbox | 14 scene.add textbox |
11 textbox.mesh.transform = scale(0.01, 0.01) | 15 textbox.mesh.transform = scale(0.01, 0.01) |
12 var engine = initEngine("Test fonts") | 16 engine.loadScene(scene) |
13 engine.initRenderer([]) | |
14 engine.addScene(scene) | |
15 | 17 |
16 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): | 18 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): |
17 if engine.windowWasResized(): | 19 if engine.windowWasResized(): |
18 var winSize = engine.getWindow().size | 20 var winSize = engine.getWindow().size |
19 textbox.mesh.transform = scale(0.01 * (winSize[1] / winSize[0]), 0.01) | 21 textbox.mesh.transform = scale(0.01 * (winSize[1] / winSize[0]), 0.01) |