fp: Render info text with RFUI

This commit is contained in:
doyle 2023-09-20 23:35:38 +10:00
parent 528a79548b
commit 8db9182fd9
4 changed files with 67 additions and 32 deletions

2
External/tely vendored

@ -1 +1 @@
Subproject commit 7bdc04915a3cc320f920f2b9b25ad811463b6fd1
Subproject commit 82dffbc84d4119c0cc5b8d72972f0f4eaef83fa4

View File

@ -1102,40 +1102,14 @@ void TELY_DLL_FrameUpdate(void *user_data)
TELY_Assets *assets = &platform->assets;
TELY_Renderer *renderer = &platform->renderer;
FP_Game *game = DQN_CAST(FP_Game *) platform->user_data;
TELY_RFui *rfui = &game->rfui;
TELY_Render_ClearColourV3(renderer, TELY_COLOUR_BLACK_MIDNIGHT_V4.rgb);
TELY_Render_PushFont(renderer, game->jetbrains_mono_font);
{
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
Dqn_String8Builder builder = {};
builder.allocator = scratch.allocator;
Dqn_String8Builder_AppendF(&builder, "TELY");
if (Dqn_String8_IsValid(platform->core.os_name))
Dqn_String8Builder_AppendF(&builder, " | %.*s", DQN_STRING_FMT(platform->core.os_name));
Dqn_String8Builder_AppendF(&builder,
" | %dx%d %.1fHz | TSC %.1f GHz",
platform->core.display.size.w,
platform->core.display.size.h,
platform->core.display.refresh_rate,
platform->core.tsc_per_second / 1'000'000'000.0);
if (platform->core.ram_mb)
Dqn_String8Builder_AppendF(&builder, " | RAM %.1fGB", platform->core.ram_mb / 1024.0);
Dqn_String8Builder_AppendF(&builder,
" | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs",
input->work_ms,
input->work_ms * 100.0 / input->delta_ms,
1000.0 / input->delta_ms,
input->frame_counter,
input->timer_s);
Dqn_String8 info_label = Dqn_String8Builder_Build(&builder, scratch.allocator);
TELY_Render_Text(renderer, /*position*/ Dqn_V2_InitNx1(10), /*align*/ Dqn_V2_InitNx1(0), info_label);
}
TELY_RFui_FrameSetup(rfui, &platform->frame_arena);
TELY_RFui_PushFont(rfui, game->jetbrains_mono_font);
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4);
// =============================================================================================
@ -1186,5 +1160,65 @@ void TELY_DLL_FrameUpdate(void *user_data)
FP_GameUpdate(platform, game, renderer, input);
FP_GameRender(game, platform, renderer);
{
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); };
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));
info_bar.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
info_bar.widget->semantic_position[TELY_RFuiAxis_X].value = 10.f;
info_bar.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute;
info_bar.widget->semantic_position[TELY_RFuiAxis_Y].value = 10.f;
TELY_RFui_PushParent(rfui, info_bar.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); };
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
Dqn_String8Builder builder = {};
builder.allocator = scratch.allocator;
TELY_RFui_TextF(rfui, "TELY");
Dqn_String8Builder_AppendF(&builder, "TELY");
if (Dqn_String8_IsValid(platform->core.os_name)) {
TELY_RFui_TextF(rfui, " | %.*s", DQN_STRING_FMT(platform->core.os_name));
Dqn_String8Builder_AppendF(&builder, " | %.*s", DQN_STRING_FMT(platform->core.os_name));
}
Dqn_String8Builder_AppendF(&builder,
" | %dx%d %.1fHz | TSC %.1f GHz",
platform->core.display.size.w,
platform->core.display.size.h,
platform->core.display.refresh_rate,
platform->core.tsc_per_second / 1'000'000'000.0);
TELY_RFui_TextF(rfui,
" | %dx%d %.1fHz | TSC %.1f GHz",
platform->core.display.size.w,
platform->core.display.size.h,
platform->core.display.refresh_rate,
platform->core.tsc_per_second / 1'000'000'000.0);
if (platform->core.ram_mb) {
Dqn_String8Builder_AppendF(&builder, " | RAM %.1fGB", platform->core.ram_mb / 1024.0);
TELY_RFui_TextF(rfui, " | RAM %.1fGB", platform->core.ram_mb / 1024.0);
}
Dqn_String8Builder_AppendF(&builder,
" | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs",
input->work_ms,
input->work_ms * 100.0 / input->delta_ms,
1000.0 / input->delta_ms,
input->frame_counter,
input->timer_s);
TELY_RFui_TextF(rfui,
" | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs",
input->work_ms,
input->work_ms * 100.0 / input->delta_ms,
1000.0 / input->delta_ms,
input->frame_counter,
input->timer_s);
}
TELY_RFui_Flush(rfui, renderer, input, assets);
TELY_Audio_MixPlaybackSamples(audio, assets);
}

View File

@ -148,4 +148,5 @@ struct FP_Game
FP_GameEntityHandle prev_hot_entity;
FP_GameEntityHandle prev_active_entity;
FP_GameCamera camera;
TELY_RFui rfui;
};

View File

@ -23,7 +23,7 @@ static Dqn_M2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera, TELY_Platform
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(rotate_origin));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Rotate(camera.rotate_rads));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Scale(camera.scale));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate((rotate_origin * -1) + camera.world_pos));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(-rotate_origin + camera.world_pos));
}
return result;
}