41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
#version 450
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
#include "ui_common.glsl"
|
|
|
|
layout(local_size_x = 1) in;
|
|
|
|
void main() {
|
|
uint gID = gl_GlobalInvocationID.x;
|
|
String string = pc.container.strings.s[gID];
|
|
|
|
// Dead slot or no glyph reservation
|
|
if(string.scratch == 0xFFFFFFFF) {
|
|
return;
|
|
}
|
|
|
|
Font font = pc.container.context.fonts.f[string.font];
|
|
vec2 pen = vec2(0.0, 0.0);
|
|
|
|
for(uint i = 0; i < string.len; i++) {
|
|
uint code = (string.codes.c[i/4] >> (i % 4)*8) & 0xFF;
|
|
Symbol symbol = font.symbols.s[code];
|
|
uint slot = string.scratch + i;
|
|
pc.container.drawables.d[slot].pos = string.pos + pen;
|
|
pen += string.size*symbol.advance;
|
|
pc.container.drawables.d[slot].size = vec2(string.size, string.size);
|
|
pc.container.drawables.d[slot].color[0] = string.color;
|
|
pc.container.drawables.d[slot].color[1] = string.color;
|
|
pc.container.drawables.d[slot].color[2] = string.color;
|
|
pc.container.drawables.d[slot].color[3] = string.color;
|
|
pc.container.drawables.d[slot].var = code + (string.font << 16);
|
|
pc.container.drawables.d[slot].type = 1;
|
|
}
|
|
|
|
// Reserved-but-unused slots stay in the index list; tombstone them so
|
|
// shrinking text doesn't leave stale quads
|
|
for(uint i = string.len; i < string.max_len; i++) {
|
|
pc.container.drawables.d[string.scratch + i].type = 0xFFFFFFFF;
|
|
}
|
|
}
|