[WIP] Add text rendering

This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent 3bd14b20c2
commit b2508ce4ff
15 files changed
+248 -27

No files matched your search

+16 -11
View File
@@ -1,4 +1,5 @@
#include "rse_graphics.h"
#include "src/rse_text_renderer.h"
#include "window.h"
#include "vulkan_base.h"
@@ -8,11 +9,13 @@
#include "utilities/logger.h"
#include "utilities/rse_commons.h"
#include "utilities/rse_errors_common.h"
#include "rse_font_errors.h"
#include "rse_math.h"
extern struct rse_vulkan_state_t g_vulkan_state;
rse_err_t rse_graphics_init(void)
{
rse_err_t status = RSE_ERROR_NO_ERROR;
@@ -36,21 +39,23 @@ void rse_graphics_test_function(void)
rse_err_t status = RSE_ERROR_NO_ERROR;
uint16_t tex_id_2 = 0;
status = rse_load_texture("../../test_image.jpg", &tex_id_2);
status = rse_load_texture_from_file("../../test_image.jpg", &tex_id_2);
if (status != RSE_ERROR_NO_ERROR) {
LOGE("Failed to do something. Check error messages");
LOGE("Failed to do something. Check error messages. Error: %d", status);
return;
}
(rse_fonts_initialize());
(rse_fonts_load_from_file("/usr/share/fonts/JetBrainsMonoNerdFont/JetBrainsMonoNerdFont-Medium.ttf"));
// FIXME: Temporary array of vertices, for testing purposes
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
{{0.5f, -0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
{{0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
{{0.5f, -0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
{{0.5f, 0.5f, -0.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
{{0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
{{0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
// FIXME: Temporary array of vertices, for testing purposes
@@ -61,14 +66,14 @@ void rse_graphics_test_function(void)
{0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, rse_math_deg_to_radians(45.0f)},
1.0f,
tex_id_2
4
});
create_mesh_instance(mesh_id, (struct rse_instance_data_t){
{-1.0f, 0.0f, 0.3f},
{0.0f, 0.0f, 0.0f},
1.0f,
tex_id_2
49
});
mesh_id = create_mesh(vertices2, indices, 8, 6);
@@ -76,7 +81,7 @@ void rse_graphics_test_function(void)
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, rse_math_deg_to_radians(0.0f)},
1.0f,
tex_id_2
33
});
}