Mercurial > games > semicongine
comparison tests/test_text.nim @ 1400:20602878744e
did: finished basic implementation of new glyph-rendering system
author | sam <sam@basx.dev> |
---|---|
date | Mon, 16 Dec 2024 00:27:40 +0700 |
parents | dde74be11b49 |
children | 4ecb004ee7f8 |
comparison
equal
deleted
inserted
replaced
1399:dde74be11b49 | 1400:20602878744e |
---|---|
16 | 16 |
17 type EMPTY = object | 17 type EMPTY = object |
18 | 18 |
19 const MAX_GLYPHS = 200 | 19 const MAX_GLYPHS = 200 |
20 proc test_01_static_label_new(time: float32) = | 20 proc test_01_static_label_new(time: float32) = |
21 # var font = loadFont("Overhaul.ttf", lineHeightPixels = 160) | 21 var font = loadFont[MAX_GLYPHS]("Overhaul.ttf", lineHeightPixels = 200) |
22 var font = loadFont[MAX_GLYPHS]("DejaVuSans.ttf", lineHeightPixels = 160) | 22 var renderdata = initRenderData() |
23 var renderdata = initRenderData() | 23 var pipeline = |
24 var pipeline = | 24 createPipeline[GlyphShader[MAX_GLYPHS]](renderPass = vulkan.swapchain.renderPass) |
25 createPipeline[GlyphShader[MAX_GLYPHS]](renderPass = vulkan.swapchain.renderPass) | 25 var glyphs = font.initGlyphs(1000, baseScale = 0.3) |
26 var glyphs = initGlyphs(1000) | |
27 | 26 |
28 assignBuffers(renderdata, glyphs) | 27 assignBuffers(renderdata, glyphs) |
29 assignBuffers(renderdata, font.descriptorSet) | 28 assignBuffers(renderdata, font.descriptorSet) |
30 uploadImages(renderdata, font.descriptorSet) | 29 uploadImages(renderdata, font.descriptorSet) |
31 initDescriptorSet(renderdata, pipeline.layout(0), font.descriptorSet) | 30 initDescriptorSet(renderdata, pipeline.layout(0), font.descriptorSet) |
32 | 31 |
33 glyphs.set(font[], "semicongine".toRunes(), vec3()) | 32 var start = getMonoTime() |
34 | 33 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: |
35 glyphs.updateAllGPUBuffers(flush = true) | 34 let t = getMonoTime() |
36 | 35 glyphs.reset() |
37 var start = getMonoTime() | 36 glyphs.add("semicongine".toRunes()) |
38 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: | 37 glyphs.updateAllGPUBuffers(flush = true) |
38 | |
39 withNextFrame(framebuffer, commandbuffer): | 39 withNextFrame(framebuffer, commandbuffer): |
40 bindDescriptorSet(commandbuffer, font.descriptorSet, 0, pipeline) | 40 bindDescriptorSet(commandbuffer, font.descriptorSet, 0, pipeline) |
41 withRenderPass( | 41 withRenderPass( |
42 vulkan.swapchain.renderPass, | 42 vulkan.swapchain.renderPass, |
43 framebuffer, | 43 framebuffer, |
47 vec4(0, 0, 0, 0), | 47 vec4(0, 0, 0, 0), |
48 ): | 48 ): |
49 withPipeline(commandbuffer, pipeline): | 49 withPipeline(commandbuffer, pipeline): |
50 renderGlyphs(commandbuffer, pipeline, glyphs) | 50 renderGlyphs(commandbuffer, pipeline, glyphs) |
51 | 51 |
52 # cleanup | 52 # cleanup |
53 checkVkResult vkDeviceWaitIdle(vulkan.device) | 53 checkVkResult vkDeviceWaitIdle(vulkan.device) |
54 destroyPipeline(pipeline) | 54 destroyPipeline(pipeline) |
55 destroyRenderData(renderdata) | 55 destroyRenderData(renderdata) |
56 | 56 |
57 #[ | 57 #[ |