Mercurial > games > semicongine
annotate tests/test_text.nim @ 1344:18eff4d97ab0
fix: stupidity
author | sam <sam@basx.dev> |
---|---|
date | Mon, 26 Aug 2024 20:24:29 +0700 |
parents | f2ff6f624932 |
children |
rev | line source |
---|---|
1236 | 1 import std/os |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
2 import std/algorithm |
1238
03634915bbdb
add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents:
1237
diff
changeset
|
3 import std/strutils |
1236 | 4 import std/sequtils |
5 import std/monotimes | |
6 import std/times | |
7 import std/options | |
8 import std/random | |
9 | |
1267 | 10 import ../semicongine |
1236 | 11 |
1332 | 12 type FontDS = object |
13 fontAtlas: Image[Gray] | |
1327 | 14 |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
15 proc test_01_static_label(time: float32) = |
1327 | 16 var font = loadFont("Overhaul.ttf", lineHeightPixels = 160) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
17 var renderdata = initRenderData() |
1332 | 18 var pipeline = |
19 createPipeline[DefaultFontShader[FontDS]](renderPass = vulkan.swapchain.renderPass) | |
1236 | 20 |
1335 | 21 var ds = asDescriptorSetData(FontDS(fontAtlas: font.fontAtlas.copy())) |
1327 | 22 uploadImages(renderdata, ds) |
1332 | 23 initDescriptorSet(renderdata, pipeline.layout(0), ds) |
1236 | 24 |
1332 | 25 var label1 = |
26 initTextbox(renderdata, pipeline.layout(0), font, 0.0005, "Hello semicongine!") | |
1236 | 27 |
28 var start = getMonoTime() | |
29 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
30 label1.refresh() |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
31 withNextFrame(framebuffer, commandbuffer): |
1327 | 32 bindDescriptorSet(commandbuffer, ds, 0, pipeline) |
1332 | 33 withRenderPass( |
34 vulkan.swapchain.renderPass, | |
35 framebuffer, | |
36 commandbuffer, | |
37 vulkan.swapchain.width, | |
38 vulkan.swapchain.height, | |
39 vec4(0, 0, 0, 0), | |
40 ): | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
41 withPipeline(commandbuffer, pipeline): |
1327 | 42 render(commandbuffer, pipeline, label1, vec3(), vec4(1, 1, 1, 1)) |
1236 | 43 |
44 # cleanup | |
45 checkVkResult vkDeviceWaitIdle(vulkan.device) | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
46 destroyPipeline(pipeline) |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
47 destroyRenderData(renderdata) |
1236 | 48 |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
49 proc test_02_multiple_animated(time: float32) = |
1282
3308b88e53a6
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1281
diff
changeset
|
50 var font1 = loadFont("Overhaul.ttf", lineHeightPixels = 40) |
3308b88e53a6
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1281
diff
changeset
|
51 var font2 = loadFont("Overhaul.ttf", lineHeightPixels = 160) |
3308b88e53a6
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1281
diff
changeset
|
52 var font3 = loadFont("DejaVuSans.ttf", lineHeightPixels = 160) |
1327 | 53 var renderdata = initRenderData() |
54 | |
1332 | 55 var pipeline = |
56 createPipeline[DefaultFontShader[FontDS]](renderPass = vulkan.swapchain.renderPass) | |
1327 | 57 |
1335 | 58 var ds1 = asDescriptorSetData(FontDS(fontAtlas: font1.fontAtlas.copy())) |
1327 | 59 uploadImages(renderdata, ds1) |
60 initDescriptorSet(renderdata, pipeline.layout(0), ds1) | |
61 | |
1335 | 62 var ds2 = asDescriptorSetData(FontDS(fontAtlas: font2.fontAtlas.copy())) |
1327 | 63 uploadImages(renderdata, ds2) |
64 initDescriptorSet(renderdata, pipeline.layout(0), ds2) | |
65 | |
1335 | 66 var ds3 = asDescriptorSetData(FontDS(fontAtlas: font3.fontAtlas.copy())) |
1327 | 67 uploadImages(renderdata, ds3) |
68 initDescriptorSet(renderdata, pipeline.layout(0), ds3) | |
69 | |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
70 var labels = [ |
1332 | 71 initTextbox(renderdata, pipeline.layout(0), font1, 0.004, " 0"), |
72 initTextbox(renderdata, pipeline.layout(0), font2, 0.001, " 1"), | |
73 initTextbox(renderdata, pipeline.layout(0), font3, 0.001, " 2"), | |
1237
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 var start = getMonoTime() |
1238
03634915bbdb
add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents:
1237
diff
changeset
|
77 var p = 0 |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
78 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: |
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
79 let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time |
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
80 for i in 0 ..< labels.len: |
1238
03634915bbdb
add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents:
1237
diff
changeset
|
81 labels[i].text = $(p + i) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
82 labels[i].refresh() |
1238
03634915bbdb
add: tests for updating texts, does not pass validation atm
sam <sam@basx.dev>
parents:
1237
diff
changeset
|
83 inc p |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
84 withNextFrame(framebuffer, commandbuffer): |
1332 | 85 withRenderPass( |
86 vulkan.swapchain.renderPass, | |
87 framebuffer, | |
88 commandbuffer, | |
89 vulkan.swapchain.width, | |
90 vulkan.swapchain.height, | |
91 vec4(0, 0, 0, 0), | |
92 ): | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
93 withPipeline(commandbuffer, pipeline): |
1327 | 94 bindDescriptorSet(commandbuffer, ds1, 0, pipeline) |
95 render( | |
96 commandbuffer, | |
97 pipeline, | |
98 labels[0], | |
1332 | 99 position = vec3(0 / labels.len, 0.1 + progress * 0.5), |
100 color = vec4(1, 1, 1, 1), | |
1327 | 101 ) |
102 bindDescriptorSet(commandbuffer, ds2, 0, pipeline) | |
103 render( | |
104 commandbuffer, | |
105 pipeline, | |
106 labels[1], | |
1332 | 107 position = vec3(1 / labels.len, 0.1 + progress * 0.5), |
108 color = vec4(1, 1, 1, 1), | |
1327 | 109 ) |
110 bindDescriptorSet(commandbuffer, ds3, 0, pipeline) | |
111 render( | |
112 commandbuffer, | |
113 pipeline, | |
114 labels[2], | |
1332 | 115 position = vec3(2 / labels.len, 0.1 + progress * 0.5), |
116 color = vec4(1, 1, 1, 1), | |
1327 | 117 ) |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
118 |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
119 # cleanup |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
120 checkVkResult vkDeviceWaitIdle(vulkan.device) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
121 destroyPipeline(pipeline) |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
122 destroyRenderData(renderdata) |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
123 |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
124 proc test_03_layouting(time: float32) = |
1327 | 125 var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 40) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
126 var renderdata = initRenderData() |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
127 |
1332 | 128 var pipeline = |
129 createPipeline[DefaultFontShader[FontDS]](renderPass = vulkan.swapchain.renderPass) | |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
130 |
1335 | 131 var ds = asDescriptorSetData(FontDS(fontAtlas: font.fontAtlas.copy())) |
1327 | 132 uploadImages(renderdata, ds) |
1332 | 133 initDescriptorSet(renderdata, pipeline.layout(0), ds) |
1327 | 134 |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
135 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
|
136 |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
137 for horizontal in HorizontalAlignment: |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
138 labels.add initTextbox( |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
139 renderdata, |
1292
5de466f5f087
add: color utils and textbox refactoring
sam <sam@basx.dev>
parents:
1283
diff
changeset
|
140 pipeline.layout(0), |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
141 font, |
1327 | 142 0.001, |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
143 $horizontal & " aligned", |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
144 horizontalAlignment = horizontal, |
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 for vertical in VerticalAlignment: |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
147 labels.add initTextbox( |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
148 renderdata, |
1292
5de466f5f087
add: color utils and textbox refactoring
sam <sam@basx.dev>
parents:
1283
diff
changeset
|
149 pipeline.layout(0), |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
150 font, |
1327 | 151 0.001, |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
152 $vertical & " aligned", |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
153 verticalAlignment = vertical, |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
154 ) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
155 labels.add initTextbox( |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
156 renderdata, |
1292
5de466f5f087
add: color utils and textbox refactoring
sam <sam@basx.dev>
parents:
1283
diff
changeset
|
157 pipeline.layout(0), |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
158 font, |
1327 | 159 0.001, |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
160 """Paragraph |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
161 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
|
162 |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
163 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
|
164 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
|
165 verticalAlignment = Top, |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
166 horizontalAlignment = Left, |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
167 ) |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
168 |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
169 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
|
170 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
|
171 let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
172 withNextFrame(framebuffer, commandbuffer): |
1327 | 173 bindDescriptorSet(commandbuffer, ds, 0, pipeline) |
1332 | 174 withRenderPass( |
175 vulkan.swapchain.renderPass, | |
176 framebuffer, | |
177 commandbuffer, | |
178 vulkan.swapchain.width, | |
179 vulkan.swapchain.height, | |
180 vec4(0, 0, 0, 0), | |
181 ): | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
182 withPipeline(commandbuffer, pipeline): |
1327 | 183 for i in 0 ..< labels.len: |
1332 | 184 render( |
185 commandbuffer, | |
186 pipeline, | |
187 labels[i], | |
188 vec3(0.5 - i.float32 * 0.1, 0.5 - i.float32 * 0.1), | |
189 vec4(1, 1, 1, 1), | |
190 ) | |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
191 |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
192 # cleanup |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
193 checkVkResult vkDeviceWaitIdle(vulkan.device) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
194 destroyPipeline(pipeline) |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
195 destroyRenderData(renderdata) |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
196 |
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
197 proc test_04_lots_of_texts(time: float32) = |
1327 | 198 var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 160) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
199 var renderdata = initRenderData() |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
200 |
1332 | 201 var pipeline = |
202 createPipeline[DefaultFontShader[FontDS]](renderPass = vulkan.swapchain.renderPass) | |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
203 |
1335 | 204 var ds = asDescriptorSetData(FontDS(fontAtlas: font.fontAtlas.copy())) |
1327 | 205 uploadImages(renderdata, ds) |
1332 | 206 initDescriptorSet(renderdata, pipeline.layout(0), ds) |
1327 | 207 |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
208 var labels: seq[Textbox] |
1327 | 209 var positions = newSeq[Vec3f](100) |
210 var colors = newSeq[Vec4f](100) | |
1329 | 211 var scales = newSeq[Vec2f](100) |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
212 for i in 0 ..< 100: |
1327 | 213 positions[i] = vec3(rand(-0.5 .. 0.5), rand(-0.5 .. 0.5), rand(-0.1 .. 0.1)) |
1332 | 214 colors[i] = |
215 vec4(rand(0.5 .. 1.0), rand(0.5 .. 1.0), rand(0.5 .. 1.0), rand(0.5 .. 1.0)) | |
1329 | 216 scales[i] = vec2(rand(0.5'f32 .. 1.5'f32), rand(0.5'f32 .. 1.5'f32)) |
1332 | 217 labels.add initTextbox(renderdata, pipeline.layout(0), font, 0.001, $i) |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
218 |
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
219 var start = getMonoTime() |
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
220 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: |
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
221 for l in labels.mitems: |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
222 l.refresh() |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
223 withNextFrame(framebuffer, commandbuffer): |
1327 | 224 bindDescriptorSet(commandbuffer, ds, 0, pipeline) |
1332 | 225 withRenderPass( |
226 vulkan.swapchain.renderPass, | |
227 framebuffer, | |
228 commandbuffer, | |
229 vulkan.swapchain.width, | |
230 vulkan.swapchain.height, | |
231 vec4(0, 0, 0, 0), | |
232 ): | |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
233 withPipeline(commandbuffer, pipeline): |
1327 | 234 for i in 0 ..< labels.len: |
1332 | 235 render( |
236 commandbuffer, pipeline, labels[i], positions[i], colors[i], scales[i] | |
237 ) | |
1240
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
238 |
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
239 # cleanup |
42eeb59f3a43
add: more tests, line and point rendering
sam <sam@basx.dev>
parents:
1239
diff
changeset
|
240 checkVkResult vkDeviceWaitIdle(vulkan.device) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
241 destroyPipeline(pipeline) |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
242 destroyRenderData(renderdata) |
1237
97813ac43cfb
add: multi-text with all properties animated
sam <sam@basx.dev>
parents:
1236
diff
changeset
|
243 |
1236 | 244 when isMainModule: |
1241
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
245 var time = 1'f32 |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
246 initVulkan() |
1236 | 247 |
1241
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
248 for depthBuffer in [true, false]: |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
249 var renderpass = createDirectPresentationRenderPass(depthBuffer = depthBuffer) |
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
250 setupSwapchain(renderpass = renderpass) |
1236 | 251 |
1241
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
252 # tests a simple triangle with minimalistic shader and vertex format |
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
253 test_01_static_label(time) |
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
254 test_02_multiple_animated(time) |
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
255 test_03_layouting(time) |
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
256 test_04_lots_of_texts(time) |
1239
69489a678141
add: better syncing, better swapchain access, correct font offset, two font-rendering tests
sam <sam@basx.dev>
parents:
1238
diff
changeset
|
257 |
1241
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
258 checkVkResult vkDeviceWaitIdle(vulkan.device) |
a0ed1a918fda
fix: letters sometimes overlapping other letters quad
sam <sam@basx.dev>
parents:
1240
diff
changeset
|
259 vkDestroyRenderPass(vulkan.device, renderpass.vk, nil) |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
260 clearSwapchain() |
1236 | 261 |
1283
0369fa1ffbd9
did: undo part of stupid API renaming a few weeks back ;(
sam <sam@basx.dev>
parents:
1282
diff
changeset
|
262 destroyVulkan() |