FPS
This commit is contained in:
42
src/ui/ui.c
42
src/ui/ui.c
@@ -6,21 +6,59 @@
|
||||
*/
|
||||
|
||||
#include "ui.h"
|
||||
#include "ui/uiconsole.h"
|
||||
#include "ui/uifps.h"
|
||||
#include "util/memory.h"
|
||||
#include "display/tileset/tileset_minogram.h"
|
||||
#include "display/screen.h"
|
||||
|
||||
ui_t UI;
|
||||
|
||||
void uiInit(void) {
|
||||
errorret_t uiInit(void) {
|
||||
memoryZero(&UI, sizeof(ui_t));
|
||||
|
||||
cameraInitOrthographic(&UI.camera);
|
||||
|
||||
// Initialize UI components here
|
||||
uiSetFont(&TILESET_MINOGRAM);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void uiUpdate(void) {
|
||||
// Update UI state here
|
||||
UI.camera.orthographic.left = 0;
|
||||
UI.camera.orthographic.right = SCREEN.width;
|
||||
UI.camera.orthographic.top = 0;
|
||||
UI.camera.orthographic.bottom = SCREEN.height;
|
||||
}
|
||||
|
||||
void uiRender(void) {
|
||||
|
||||
cameraPushMatrix(&UI.camera);
|
||||
|
||||
// Render UI elements here
|
||||
if(UI.font) {
|
||||
uiConsoleRender(0, 0, UI.fontTileset, &UI.font->alphaImage.texture);
|
||||
uiFPSRender(UI.fontTileset, &UI.font->alphaImage.texture);
|
||||
}
|
||||
|
||||
cameraPopMatrix();
|
||||
}
|
||||
|
||||
errorret_t uiSetFont(const tileset_t *fontTileset) {
|
||||
if(UI.font) {
|
||||
assetUnlock(UI.font, UI.fontRef);
|
||||
UI.font = NULL;
|
||||
}
|
||||
|
||||
UI.fontTileset = fontTileset;
|
||||
assetManagerLoadAsset(fontTileset->image, &UI.font, &UI.fontRef);
|
||||
}
|
||||
|
||||
void uiDispose(void) {
|
||||
// Clean up UI resources here
|
||||
if(UI.font) {
|
||||
assetUnlock(UI.font, UI.fontRef);
|
||||
UI.font = NULL;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user