add ui module

This commit is contained in:
asrael 2025-10-04 11:55:04 -05:00
parent 1744e689b5
commit 6008ebf5ed
12 changed files with 703 additions and 215 deletions

View file

@ -31,14 +31,14 @@ pxl8_result pxl8_font_create_atlas(const pxl8_font* font, u8** atlas_data, i32*
for (i32 y = 0; y < glyph->height && y < font->default_height; y++) {
for (i32 x = 0; x < glyph->width && x < font->default_width; x++) {
i32 glyph_idx = y * 8 + x;
i32 atlas_idx = (atlas_y + y) * (*atlas_width) + (atlas_x + x);
if (glyph->format == PXL8_FONT_FORMAT_INDEXED) {
u8 pixel_byte = glyph->data.indexed[glyph_idx / 8];
u8 pixel_bit = (pixel_byte >> (7 - (glyph_idx % 8))) & 1;
u8 pixel_byte = glyph->data.indexed[y];
u8 pixel_bit = (pixel_byte >> x) & 1;
(*atlas_data)[atlas_idx] = pixel_bit ? 255 : 0;
} else {
i32 glyph_idx = y * 8 + x;
u32 rgba_pixel = glyph->data.rgba[glyph_idx];
(*atlas_data)[atlas_idx] = (rgba_pixel >> 24) & 0xFF;
}