FPS toggle
This commit is contained in:
@@ -34,6 +34,8 @@ errorret_t uiInit(void) {
|
||||
|
||||
UI.scale = 2.0f;
|
||||
|
||||
uiFPSInit();
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
@@ -8,4 +8,5 @@
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
void uiFPSInit(void);
|
||||
void uiFPSRender(void);
|
Reference in New Issue
Block a user