comparison tests/test_text.nim @ 1398:f7bf7a5cc1e7

sync from bedroom to office
author sam <sam@basx.dev>
date Sat, 14 Dec 2024 17:17:51 +0700
parents 4fd96b36696a
children dde74be11b49
comparison
equal deleted inserted replaced
1397:4fd96b36696a 1398:f7bf7a5cc1e7
16 16
17 type EMPTY = object 17 type EMPTY = object
18 18
19 const N_GLYPHS = 200 19 const N_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("Overhaul.ttf", lineHeightPixels = 160)
22 var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 160)
22 var renderdata = initRenderData() 23 var renderdata = initRenderData()
23 var pipeline = 24 var pipeline =
24 createPipeline[GlyphShader[N_GLYPHS]](renderPass = vulkan.swapchain.renderPass) 25 createPipeline[GlyphShader[N_GLYPHS]](renderPass = vulkan.swapchain.renderPass)
25 var (ds, glyphtable) = glyphDescriptorSet(font, N_GLYPHS) 26 var (ds, glyphtable) = glyphDescriptorSet(font, N_GLYPHS)
26 var glyphs = Glyphs( 27 var glyphs = Glyphs(
27 position: 28 position: asGPUArray(
28 asGPUArray([vec3(0, 0, 0.2), vec3(0, 0, 0.1), vec3(0, 0, 0)], VertexBufferMapped), 29 [
29 scale: asGPUArray([1'f32, 1'f32, 1'f32], VertexBufferMapped), 30 vec3(-1, 0, 0),
31 vec3(-0.6, 0, 0),
32 vec3(-0.3, 0, 0),
33 vec3(0, 0, 0),
34 vec3(0.3, 0, 0),
35 vec3(0.6, 0, 0),
36 ],
37 VertexBufferMapped,
38 ),
39 scale: asGPUArray([1'f32, 1'f32, 1'f32, 1'f32, 1'f32, 1'f32], VertexBufferMapped),
30 color: asGPUArray( 40 color: asGPUArray(
31 [vec4(1, 1, 1, 1), vec4(1, 1, 1, 1), vec4(1, 1, 1, 1)], VertexBufferMapped 41 [
42 vec4(1, 1, 0, 1),
43 vec4(0, 0, 1, 1),
44 vec4(1, 1, 1, 1),
45 vec4(1, 1, 0, 1),
46 vec4(0, 0, 1, 1),
47 vec4(1, 1, 1, 1),
48 ],
49 VertexBufferMapped,
32 ), 50 ),
33 glyphIndex: asGPUArray( 51 glyphIndex: asGPUArray(
34 [glyphtable[Rune('A')], glyphtable[Rune('B')], glyphtable[Rune('g')]], 52 [
53 glyphtable[Rune('a')],
54 glyphtable[Rune('l')],
55 glyphtable[Rune('i')],
56 glyphtable[Rune('g')],
57 glyphtable[Rune('x')],
58 glyphtable[Rune('x')],
59 ],
35 VertexBufferMapped, 60 VertexBufferMapped,
36 ), 61 ),
37 ) 62 )
38 63
39 assignBuffers(renderdata, glyphs) 64 assignBuffers(renderdata, glyphs)
57 render( 82 render(
58 commandbuffer, 83 commandbuffer,
59 pipeline, 84 pipeline,
60 EMPTY(), 85 EMPTY(),
61 glyphs, 86 glyphs,
62 fixedVertexCount = 6, 87 fixedVertexCount = 6, # fixedInstanceCount = 2,
63 fixedInstanceCount = 2,
64 ) 88 )
65 89
66 # cleanup 90 # cleanup
67 checkVkResult vkDeviceWaitIdle(vulkan.device) 91 checkVkResult vkDeviceWaitIdle(vulkan.device)
68 destroyPipeline(pipeline) 92 destroyPipeline(pipeline)