# HG changeset patch # User sam # Date 1721536271 -25200 # Node ID 03634915bbdb5c611c3ccbcc394becf1b5c0f89d # Parent 97813ac43cfbcf635db610920138d56865cde01c add: tests for updating texts, does not pass validation atm diff -r 97813ac43cfb -r 03634915bbdb semiconginev2/text/textbox.nim --- a/semiconginev2/text/textbox.nim Sun Jul 21 00:03:48 2024 +0700 +++ b/semiconginev2/text/textbox.nim Sun Jul 21 11:31:11 2024 +0700 @@ -97,6 +97,8 @@ textbox.position.data[vertexOffset + 1] = NewVec3f() textbox.position.data[vertexOffset + 2] = NewVec3f() textbox.position.data[vertexOffset + 3] = NewVec3f() + UpdateGPUBuffer(textbox.position, flush = true) + UpdateGPUBuffer(textbox.uv, flush = true) textbox.lastRenderedText = textbox.processedText func text*(textbox: Textbox): seq[Rune] = diff -r 97813ac43cfb -r 03634915bbdb tests/test_text.nim --- a/tests/test_text.nim Sun Jul 21 00:03:48 2024 +0700 +++ b/tests/test_text.nim Sun Jul 21 11:31:11 2024 +0700 @@ -1,4 +1,5 @@ import std/os +import std/strutils import std/sequtils import std/monotimes import std/times @@ -48,7 +49,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font1, - "0", + " 0", color = NewVec4f(0, 1, 1, 1), scale = 0.004, position = NewVec3f(-0.3, 0.5) @@ -57,7 +58,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font2, - "1", + " 1", color = NewVec4f(1, 0, 1, 1), scale = 0.001, position = NewVec3f(0, 0) @@ -66,7 +67,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font3, - "2", + " 2", color = NewVec4f(1, 1, 0, 1), scale = 0.001, position = NewVec3f(0.3, -0.5) @@ -74,15 +75,18 @@ ] var start = getMonoTime() + var p = 0 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time for i in 0 ..< labels.len: var c = labels[i].Color c[i] = progress labels[i].Color = c - labels[i].Scale = labels[i].Scale * 1.002 + labels[i].Scale = labels[i].Scale * (1.0 + (i + 1).float * 0.001) labels[i].Position = labels[i].Position + NewVec3f(0.001 * (i.float - 1'f)) + labels[i].text = $(p + i) labels[i].Refresh(swapchain.GetAspectRatio()) + inc p WithNextFrame(swapchain, framebuffer, commandbuffer): WithRenderPass(swapchain.renderPass, framebuffer, commandbuffer, swapchain.width, swapchain.height, NewVec4f(0, 0, 0, 0)): WithPipeline(commandbuffer, pipeline):