draw text.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/scene/scenemanager.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/ui/rendertext.h"
|
||||
#include "display/ui/ui.h"
|
||||
#include "display/mesh/quad.h"
|
||||
|
||||
display_t DISPLAY;
|
||||
@@ -62,7 +62,7 @@ errorret_t displayInit(void) {
|
||||
quadInit();
|
||||
frameBufferInitBackbuffer();
|
||||
spriteBatchInit();
|
||||
errorChain(renderTextInit());
|
||||
errorChain(uiInit());
|
||||
sceneManagerInit();
|
||||
|
||||
errorOk();
|
||||
@@ -101,7 +101,10 @@ errorret_t displayUpdate(void) {
|
||||
);
|
||||
|
||||
sceneManagerUpdate();
|
||||
uiUpdate();
|
||||
|
||||
sceneManagerRender();
|
||||
uiRender();
|
||||
|
||||
#if DISPLAY_SDL2
|
||||
SDL_GL_SwapWindow(DISPLAY.window);
|
||||
@@ -118,7 +121,7 @@ errorret_t displayUpdate(void) {
|
||||
|
||||
errorret_t displayDispose(void) {
|
||||
sceneManagerDispose();
|
||||
renderTextDispose();
|
||||
uiDispose();
|
||||
spriteBatchDispose();
|
||||
|
||||
#if DISPLAY_SDL2
|
||||
|
@@ -16,28 +16,16 @@
|
||||
|
||||
camera_t SCENE_OVERWORLD_CAMERA;
|
||||
asset_t *testAsset;
|
||||
ref_t testAssetRef;
|
||||
|
||||
void sceneOverworldInit(void) {
|
||||
cameraInit(&SCENE_OVERWORLD_CAMERA);
|
||||
// glm_vec3_copy((vec3){32.0f, 32.0f, 32.0f}, SCENE_OVERWORLD_CAMERA.lookat.position);
|
||||
|
||||
SCENE_OVERWORLD_CAMERA.projType = CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC;
|
||||
SCENE_OVERWORLD_CAMERA.orthographic.left = 0.0f;
|
||||
SCENE_OVERWORLD_CAMERA.orthographic.right = 128.0f;
|
||||
SCENE_OVERWORLD_CAMERA.orthographic.top = 0.0f;
|
||||
SCENE_OVERWORLD_CAMERA.orthographic.bottom = 72.0f;
|
||||
SCENE_OVERWORLD_CAMERA.nearClip = -1.0f;
|
||||
SCENE_OVERWORLD_CAMERA.farClip = 1000.0f;
|
||||
|
||||
SCENE_OVERWORLD_CAMERA.viewType = CAMERA_VIEW_TYPE_MATRIX;
|
||||
glm_mat4_identity(SCENE_OVERWORLD_CAMERA.view);
|
||||
glm_vec3_copy((vec3){32.0f, 32.0f, 32.0f}, SCENE_OVERWORLD_CAMERA.lookat.position);
|
||||
|
||||
scene_t *scene = &SCENE_MANAGER_SCENES[SCENE_TYPE_OVERWORLD];
|
||||
scene->flags |= SCENE_FLAG_ACTIVE | SCENE_FLAG_VISIBLE;
|
||||
|
||||
assetManagerGetAsset("entities.dpi", &testAsset);
|
||||
ref_t lock = assetLock(testAsset);
|
||||
assetLoad(testAsset);
|
||||
assetManagerLoadAsset("entities.dpi", &testAsset, &testAssetRef);
|
||||
}
|
||||
|
||||
void sceneOverworldUpdate(void) {
|
||||
@@ -51,7 +39,7 @@ void sceneOverworldRender(void) {
|
||||
// Draw entities
|
||||
|
||||
// Draw overlay layer.
|
||||
renderTextDraw(0.0f, 0.0f, "Hello World", 0xFF, 0xFF, 0xFF);
|
||||
// renderTextDraw(0.0f, 0.0f, "Hello World", 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// spriteBatchPush(
|
||||
// &testAsset->paletteImage.texture,
|
||||
@@ -66,4 +54,5 @@ void sceneOverworldRender(void) {
|
||||
|
||||
void sceneOverworldDispose(void) {
|
||||
// Dispose of the overworld scene.
|
||||
if(testAsset) assetUnlock(testAsset, testAssetRef);
|
||||
}
|
||||
|
@@ -7,4 +7,5 @@
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
rendertext.c
|
||||
ui.c
|
||||
)
|
49
src/display/ui/ui.c
Normal file
49
src/display/ui/ui.c
Normal 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
17
src/display/ui/ui.h
Normal 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);
|
Reference in New Issue
Block a user