Draw console

This commit is contained in:
2025-08-11 23:17:15 -05:00
parent 294abab501
commit a70cd7b4d2
6 changed files with 47 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ target_sources(${DUSK_TARGET_NAME}
render.c
renderbackbuffer.c
rendertext.c
renderconsole.c
)
# Subdirs

View File

@@ -9,6 +9,7 @@
#include "assert/assert.h"
#include "renderbackbuffer.h"
#include "rendertext.h"
#include "renderconsole.h"
SDL_Window *RENDER_WINDOW;
SDL_Renderer *RENDER_RENDERER;
@@ -70,7 +71,7 @@ errorret_t renderDraw(void) {
renderBackBufferBind();
// Draw everything
renderTextDraw(0.0f, 0.0f, "Hello World!");
renderConsoleDraw();
// Unbind the backbuffer
renderBackBufferUnbind();

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "renderconsole.h"
#include "console/console.h"
#include "rendertext.h"
void renderConsoleDraw(void) {
// if(!CONSOLE.visible) return;
// renderTextDraw(0, 0, "Dusk Console");
int32_t i = 0;
char_t *line;
do {
line = CONSOLE.line[i];
if(line[0] == '\0') {
i++;
continue;
}
renderTextDraw(0, (CONSOLE_HISTORY_MAX - i - 1) * FONT_TILE_HEIGHT, line);
i++;
} while(i < CONSOLE_HISTORY_MAX);
}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusksdl2.h"
/**
* Draws the console overlay.
*/
void renderConsoleDraw(void);

View File

@@ -7,7 +7,6 @@
#include "rendertext.h"
#include "render.h"
#include "ui/font.h"
#include "assert/assert.h"
SDL_Texture* RENDER_TEXT_TEXTURE = NULL;

View File

@@ -7,6 +7,7 @@
#pragma once
#include "dusksdl2.h"
#include "ui/font.h"
extern SDL_Texture* RENDER_TEXT_TEXTURE;