annotate tests/test_text.nim @ 1239:69489a678141

add: better syncing, better swapchain access, correct font offset, two font-rendering tests
author sam <sam@basx.dev>
date Mon, 22 Jul 2024 00:46:10 +0700
parents 03634915bbdb
children 42eeb59f3a43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
1 import std/os
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
2 import std/strutils
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
3 import std/sequtils
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
4 import std/monotimes
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
5 import std/times
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
6 import std/options
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
7 import std/random
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
8
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
9 import ../semiconginev2
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
10
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
11 proc test_01_static_label(time: float32) =
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
12 var renderdata = InitRenderData()
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
13
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
14 var pipeline = CreatePipeline[DefaultFontShader](renderPass = vulkan.swapchain.renderPass)
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
15
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
16 var font = LoadFont("Overhaul.ttf", lineHeightPixels = 160)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
17 var label1 = InitTextbox(
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
18 renderdata,
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
19 pipeline.descriptorSetLayouts[0],
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
20 font,
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
21 "Hello semicongine!",
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
22 color = NewVec4f(1, 1, 1, 1),
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
23 scale = 0.0005,
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
24 )
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
25
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
26 var start = getMonoTime()
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
27 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time:
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
28 label1.Refresh()
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
29 WithNextFrame(framebuffer, commandbuffer):
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
30 WithRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, NewVec4f(0, 0, 0, 0)):
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
31 WithPipeline(commandbuffer, pipeline):
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
32 Render(label1, commandbuffer, pipeline)
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
33
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
34 # cleanup
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
35 checkVkResult vkDeviceWaitIdle(vulkan.device)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
36 DestroyPipeline(pipeline)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
37 DestroyRenderData(renderdata)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
38
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
39 proc test_02_multiple_animated(time: float32) =
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
40 var renderdata = InitRenderData()
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
41
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
42 var pipeline = CreatePipeline[DefaultFontShader](renderPass = vulkan.swapchain.renderPass)
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
43
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
44 var font1 = LoadFont("Overhaul.ttf", lineHeightPixels = 40)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
45 var font2 = LoadFont("Overhaul.ttf", lineHeightPixels = 160)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
46 var font3 = LoadFont("DejaVuSans.ttf", lineHeightPixels = 160)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
47 var labels = [
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
48 InitTextbox(
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
49 renderdata,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
50 pipeline.descriptorSetLayouts[0],
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
51 font1,
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
52 " 0",
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
53 color = NewVec4f(0, 1, 1, 1),
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
54 scale = 0.004,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
55 position = NewVec3f(-0.3, 0.5)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
56 ),
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
57 InitTextbox(
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
58 renderdata,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
59 pipeline.descriptorSetLayouts[0],
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
60 font2,
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
61 " 1",
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
62 color = NewVec4f(1, 0, 1, 1),
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
63 scale = 0.001,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
64 position = NewVec3f(0, 0)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
65 ),
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
66 InitTextbox(
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
67 renderdata,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
68 pipeline.descriptorSetLayouts[0],
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
69 font3,
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
70 " 2",
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
71 color = NewVec4f(1, 1, 0, 1),
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
72 scale = 0.001,
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
73 position = NewVec3f(0.3, -0.5)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
74 )
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
75 ]
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
76
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
77 var start = getMonoTime()
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
78 var p = 0
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
79 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time:
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
80 let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
81 for i in 0 ..< labels.len:
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
82 var c = labels[i].Color
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
83 c[i] = progress
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
84 labels[i].Color = c
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
85 labels[i].Scale = labels[i].Scale * (1.0 + (i + 1).float * 0.001)
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
86 labels[i].Position = labels[i].Position + NewVec3f(0.001 * (i.float - 1'f))
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
87 labels[i].text = $(p + i)
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
88 labels[i].Refresh()
1238
03634915bbdb add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents: 1237
diff changeset
89 inc p
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
90 WithNextFrame(framebuffer, commandbuffer):
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
91 WithRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, NewVec4f(0, 0, 0, 0)):
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
92 WithPipeline(commandbuffer, pipeline):
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
93 for label in labels:
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
94 Render(label, commandbuffer, pipeline)
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
95
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
96 # cleanup
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
97 checkVkResult vkDeviceWaitIdle(vulkan.device)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
98 DestroyPipeline(pipeline)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
99 DestroyRenderData(renderdata)
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
100
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
101 proc test_03_layouting(time: float32) =
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
102 var renderdata = InitRenderData()
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
103
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
104 var pipeline = CreatePipeline[DefaultFontShader](renderPass = vulkan.swapchain.renderPass)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
105
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
106 var font = LoadFont("DejaVuSans.ttf", lineHeightPixels = 40)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
107 var labels: seq[Textbox]
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
108
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
109 for horizontal in HorizontalAlignment:
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
110 labels.add InitTextbox(
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
111 renderdata,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
112 pipeline.descriptorSetLayouts[0],
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
113 font,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
114 $horizontal & " aligned",
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
115 color = NewVec4f(1, 1, 1, 1),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
116 scale = 0.001,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
117 position = NewVec3f(0, 0.9 - (horizontal.float * 0.15)),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
118 horizontalAlignment = horizontal,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
119 )
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
120 for vertical in VerticalAlignment:
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
121 labels.add InitTextbox(
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
122 renderdata,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
123 pipeline.descriptorSetLayouts[0],
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
124 font,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
125 $vertical & " aligned",
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
126 color = NewVec4f(1, 1, 1, 1),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
127 scale = 0.001,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
128 position = NewVec3f(-0.35 + (vertical.float * 0.35), 0.3),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
129 verticalAlignment = vertical,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
130 )
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
131 labels.add InitTextbox(
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
132 renderdata,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
133 pipeline.descriptorSetLayouts[0],
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
134 font,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
135 """Paragraph
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
136 This is a somewhat longer paragraph with a few newlines and a maximum width of 0.2.
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
137
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
138 It should display with some space above and have a pleasing appearance overall! :)""",
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
139 maxWidth = 0.6,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
140 color = NewVec4f(1, 1, 1, 1),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
141 scale = 0.001,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
142 position = NewVec3f(-0.9, 0.1),
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
143 verticalAlignment = Top,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
144 horizontalAlignment = Left,
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
145 )
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
146
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
147
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
148 var start = getMonoTime()
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
149 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time:
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
150 let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
151 WithNextFrame(framebuffer, commandbuffer):
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
152 WithRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, NewVec4f(0, 0, 0, 0)):
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
153 WithPipeline(commandbuffer, pipeline):
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
154 for label in labels:
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
155 Render(label, commandbuffer, pipeline)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
156
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
157 # cleanup
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
158 checkVkResult vkDeviceWaitIdle(vulkan.device)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
159 DestroyPipeline(pipeline)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
160 DestroyRenderData(renderdata)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
161
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
162 proc test_04_lots_of_texts(time: float32) =
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
163 discard # TODO
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
164
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
165 when isMainModule:
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
166 var time = 10'f32
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
167 InitVulkan()
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
168
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
169 var renderpass = CreateDirectPresentationRenderPass(depthBuffer = true)
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
170 SetupSwapchain(renderpass = renderpass)
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
171
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
172 # tests a simple triangle with minimalistic shader and vertex format
1237
97813ac43cfb add: multi-text with all properties animated
sam <sam@basx.dev>
parents: 1236
diff changeset
173 # test_01_static_label(time, swapchain)
1239
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
174 # test_02_multiple_animated(time)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
175 test_03_layouting(time)
69489a678141 add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents: 1238
diff changeset
176
1236
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
177
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
178 checkVkResult vkDeviceWaitIdle(vulkan.device)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
179 vkDestroyRenderPass(vulkan.device, renderpass.vk, nil)
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
180
176383220123 add: first font-rendering test
sam <sam@basx.dev>
parents:
diff changeset
181 DestroyVulkan()