ui, fix cutting bug, appearance animations, add f32_round

This commit is contained in:
Krzosa Karol
2025-01-25 14:16:41 +01:00
parent 39c9a9841e
commit 0a6654c15d
9 changed files with 368 additions and 135 deletions

View File

@@ -1,4 +1,4 @@
rn_atlas_t *rn_create_atlas(ma_arena_t *arena, v2i32_t size) {
fn rn_atlas_t *rn_create_atlas(ma_arena_t *arena, v2i32_t size) {
rn_atlas_t *result = ma_push_type(arena, rn_atlas_t);
result->size = size;
result->inverse_size.x = 1.f / (f32)result->size.x;
@@ -22,7 +22,7 @@ rn_atlas_t *rn_create_atlas(ma_arena_t *arena, v2i32_t size) {
return result;
}
r2f32_t rn_pack_bitmap(rn_atlas_t *atlas, u8 *bitmap, i32 width, i32 height) {
fn r2f32_t rn_pack_bitmap(rn_atlas_t *atlas, u8 *bitmap, i32 width, i32 height) {
// Packing into a texture atlas
// @Inefficient The algorithm is a simplest thing I had in mind, first we advance
// through the atlas in X packing consecutive glyphs. After we get to the end of the row
@@ -59,7 +59,7 @@ r2f32_t rn_pack_bitmap(rn_atlas_t *atlas, u8 *bitmap, i32 width, i32 height) {
return result;
}
rn_font_t *rn_create_font(ma_arena_t *arena) {
fn rn_font_t *rn_create_font(ma_arena_t *arena) {
rn_font_t *font = ma_push_type(arena, rn_font_t);
font->first_char = ' ';
font->last_char = '~';
@@ -68,7 +68,7 @@ rn_font_t *rn_create_font(ma_arena_t *arena) {
return font;
}
b32 rn_reload_font_atlas(rn_font_t *font, s8_t font_data, rn_atlas_t *atlas, i32 size) {
fn b32 rn_reload_font_atlas(rn_font_t *font, s8_t font_data, rn_atlas_t *atlas, i32 size) {
font->glyph_count = 0;
stbtt_fontinfo stb_font;
i32 success = stbtt_InitFont(&stb_font, (const unsigned char *)font_data.str, 0);
@@ -107,7 +107,7 @@ b32 rn_reload_font_atlas(rn_font_t *font, s8_t font_data, rn_atlas_t *atlas, i32
return true;
}
rn_glyph_t *rn_get_glyph(rn_font_t *font, u32 codepoint) {
fn rn_glyph_t *rn_get_glyph(rn_font_t *font, u32 codepoint) {
b32 is_in_range = codepoint >= font->first_char && codepoint <= font->last_char;
if (is_in_range) {
u32 index = codepoint - font->first_char;