From 98bcb9e56fbd11688f518050ed13281a9f0ade98 Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 22 Oct 2023 22:50:18 +1100 Subject: [PATCH] fp: Scale the fonts accordingly to the window rez --- feely_pona.cpp | 16 ++++------------ feely_pona.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/feely_pona.cpp b/feely_pona.cpp index c321b98..0e8aa24 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -3,16 +3,7 @@ #include "feely_pona_unity.h" #endif -struct FP_ParticleDescriptor -{ - Dqn_String8 anim_name; - Dqn_V2 pos; - Dqn_V2 velocity; - Dqn_V2 velocity_variance; - Dqn_V4 colour_begin; - Dqn_V4 colour_end; - Dqn_usize duration_ms; -}; +Dqn_V2 const FP_TARGET_VIEWPORT_SIZE = Dqn_V2_InitNx2(1824, 1046); static FP_ParticleDescriptor FP_DefaultFloatUpParticleDescriptor(Dqn_String8 anim_name, Dqn_usize duration_ms) { @@ -398,7 +389,7 @@ static void FP_PlayReset(FP_Game *game, TELY_Platform *platform) // NOTE: Camera ================================================================================ play->camera.world_pos = {}; play->camera.scale = Dqn_V2_InitNx1(1); - play->camera.size = Dqn_V2_InitNx2(1826, 1046); + play->camera.size = FP_TARGET_VIEWPORT_SIZE; } #if defined(DQN_OS_WIN32) @@ -427,7 +418,8 @@ void TELY_DLL_Init(void *user_data) TELY_Assets *assets = &platform->assets; FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes); - uint16_t font_size = 18; + Dqn_f32 font_scalar = FP_TARGET_VIEWPORT_SIZE.w / DQN_CAST(Dqn_f32)platform->core.window_size.x; + uint16_t font_size = DQN_CAST(uint16_t)(18 * font_scalar); game->inter_regular_font_large = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Fonts/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size * 5.f)); game->inter_regular_font = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Fonts/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size)); game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Fonts/Inter-Italic.otf"), font_size); diff --git a/feely_pona.h b/feely_pona.h index 90ae298..93ad21d 100644 --- a/feely_pona.h +++ b/feely_pona.h @@ -153,6 +153,16 @@ struct FP_GlobalAnimations } g_anim_names; +struct FP_ParticleDescriptor +{ + Dqn_String8 anim_name; + Dqn_V2 pos; + Dqn_V2 velocity; + Dqn_V2 velocity_variance; + Dqn_V4 colour_begin; + Dqn_V4 colour_end; + Dqn_usize duration_ms; +}; #if defined(DQN_PLATFORM_EMSCRIPTEN) #define FP_DEVELOPER_MODE 0