Mercurial > games > semicongine
diff semiconginev2/text.nim @ 1236:176383220123
add: first font-rendering test
author | sam <sam@basx.dev> |
---|---|
date | Sat, 20 Jul 2024 17:45:44 +0700 |
parents | 841e12f33c47 |
children | a0ed1a918fda |
line wrap: on
line diff
--- a/semiconginev2/text.nim Sat Jul 20 15:45:02 2024 +0700 +++ b/semiconginev2/text.nim Sat Jul 20 17:45:44 2024 +0700 @@ -26,6 +26,7 @@ color: Vec4f position: Vec3f scale: float32 + aspectratio: float32 TextboxDescriptorSet = object textbox: GPUValue[TextboxData, UniformBufferMapped] fontAtlas: Image[Gray] @@ -36,11 +37,13 @@ fragmentUv {.Pass.}: Vec2f color {.ShaderOutput.}: Vec4f descriptorSets {.DescriptorSets.}: (TextboxDescriptorSet, ) - vertexCode = &""" - gl_Position = vec4(position * textbox.scale + textbox.position, 1.0); + vertexCode = """void main() { + gl_Position = vec4(position * vec3(1, textbox.aspectratio, 1) * textbox.scale + textbox.position, 1.0); fragmentUv = uv; - """ - fragmentCode = &"""color = vec4(textbox.color.rgb, textbox.color.rgb.a * texture(fontAtlas, fragmentUv).r);""" +} """ + fragmentCode = """void main() { + color = vec4(textbox.color.rgb, textbox.color.a * texture(fontAtlas, fragmentUv).r); +}""" include ./text/font