draw text.

This commit is contained in:
2025-09-02 23:01:15 -05:00
parent 1af2b8f47b
commit 059ccf41b6
5 changed files with 78 additions and 19 deletions

View File

@@ -7,4 +7,5 @@
target_sources(${DUSK_TARGET_NAME}
PRIVATE
rendertext.c
ui.c
)

49
src/display/ui/ui.c Normal file
View File

@@ -0,0 +1,49 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "ui.h"
#include "rendertext.h"
#include "display/framebuffer/framebuffer.h"
camera_t UI_CAMERA;
errorret_t uiInit(void) {
errorChain(renderTextInit());
cameraInit(&UI_CAMERA);
UI_CAMERA.projType = CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC;
UI_CAMERA.orthographic.left = 0.0f;
UI_CAMERA.orthographic.top = 0.0f;
UI_CAMERA.orthographic.right = frameBufferGetWidth(&FRAMEBUFFER_BACKBUFFER);
UI_CAMERA.orthographic.bottom = frameBufferGetHeight(&FRAMEBUFFER_BACKBUFFER);
UI_CAMERA.nearClip = -1.0f;
UI_CAMERA.farClip = 1.0f;
UI_CAMERA.viewType = CAMERA_VIEW_TYPE_MATRIX;
glm_mat4_identity(UI_CAMERA.view);
errorOk();
}
void uiUpdate(void) {
}
void uiRender(void) {
UI_CAMERA.orthographic.right = frameBufferGetWidth(FRAMEBUFFER_BOUND);
UI_CAMERA.orthographic.bottom = frameBufferGetHeight(FRAMEBUFFER_BOUND);
cameraPushMatrix(&UI_CAMERA);
renderTextDraw(10.0f, 10.0f, "Dusk Engine UI", 0xFF, 0xFF, 0xFF);
cameraPopMatrix();
}
void uiDispose(void) {
renderTextDispose();
}

17
src/display/ui/ui.h Normal file
View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "error/error.h"
#include "display/camera.h"
extern camera_t UI_CAMERA;
errorret_t uiInit(void);
void uiUpdate(void);
void uiRender(void);
void uiDispose(void);