1236
|
1 import std/os
|
|
2 import std/sequtils
|
|
3 import std/monotimes
|
|
4 import std/times
|
|
5 import std/options
|
|
6 import std/random
|
|
7
|
|
8 import ../semiconginev2
|
|
9
|
|
10 proc test_01_static_label(time: float32, swapchain: var Swapchain) =
|
|
11 var renderdata = InitRenderData()
|
|
12
|
|
13 # scale: float32 = 1,
|
|
14 # position: Vec3f = NewVec3f(),
|
|
15 # color: Vec4f = NewVec4f(0, 0, 0, 1),
|
|
16
|
|
17 var pipeline = CreatePipeline[DefaultFontShader](renderPass = swapchain.renderPass)
|
|
18
|
|
19 var font = LoadFont("Overhaul.ttf", lineHeightPixels = 160)
|
|
20 var label1 = InitTextbox(
|
|
21 renderdata,
|
|
22 pipeline.descriptorSetLayouts[0],
|
|
23 font,
|
|
24 "Hello semicongine!",
|
|
25 color = NewVec4f(1, 1, 1, 1),
|
|
26 scale = 0.0005,
|
|
27 )
|
|
28
|
|
29 var start = getMonoTime()
|
|
30 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time:
|
|
31 label1.Refresh(swapchain.GetAspectRatio())
|
|
32 WithNextFrame(swapchain, framebuffer, commandbuffer):
|
|
33 WithRenderPass(swapchain.renderPass, framebuffer, commandbuffer, swapchain.width, swapchain.height, NewVec4f(0, 0, 0, 0)):
|
|
34 WithPipeline(commandbuffer, pipeline):
|
|
35 Render(label1, commandbuffer, pipeline, swapchain.currentFiF)
|
|
36
|
|
37 # cleanup
|
|
38 checkVkResult vkDeviceWaitIdle(vulkan.device)
|
|
39 DestroyPipeline(pipeline)
|
|
40 DestroyRenderData(renderdata)
|
|
41
|
|
42 when isMainModule:
|
|
43 var time = 10'f32
|
|
44 InitVulkan()
|
|
45
|
|
46 var renderpass = CreateDirectPresentationRenderPass(depthBuffer = true)
|
|
47 var swapchain = InitSwapchain(renderpass = renderpass).get()
|
|
48
|
|
49 # tests a simple triangle with minimalistic shader and vertex format
|
|
50 test_01_static_label(time, swapchain)
|
|
51
|
|
52 checkVkResult vkDeviceWaitIdle(vulkan.device)
|
|
53 vkDestroyRenderPass(vulkan.device, renderpass.vk, nil)
|
|
54 DestroySwapchain(swapchain)
|
|
55
|
|
56 DestroyVulkan()
|