FPS toggle

This commit is contained in:
2025-09-11 22:25:57 -05:00
parent 268e9ffefd
commit b4d94c2cbe
5 changed files with 20 additions and 4 deletions

View File

@@ -34,6 +34,8 @@ errorret_t uiInit(void) {
UI.scale = 2.0f;
uiFPSInit();
errorOk();
}

View File

@@ -8,10 +8,20 @@
#include "uifps.h"
#include "display/ui/uitext.h"
#include "time/time.h"
#include "console/console.h"
#include "util/string.h"
void uiFPSInit(void) {
consoleRegVar("fps", "1", NULL);
}
void uiFPSRender(void) {
float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
if(stringCompare(consoleVarGet("fps")->value, "0") == 0) {
return;
}
char_t buffer[64];
snprintf(
buffer,
@@ -20,8 +30,11 @@ void uiFPSRender(void) {
(int32_t)fps
);
color_t color = fps >= 50.0f ? COLOR_GREEN :
(fps >= 30.0f ? COLOR_YELLOW : COLOR_RED);
color_t color = (
fps >= 50.0f ? COLOR_GREEN :
fps >= 30.0f ? COLOR_YELLOW :
COLOR_RED
);
uiTextDraw(0, 0, buffer, color);
}

View File

@@ -8,4 +8,5 @@
#pragma once
#include "dusk.h"
void uiFPSInit(void);
void uiFPSRender(void);