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