commit a875246
uint
·
2026-10-16 15:30:13 +0000 UTC
parent 11a2abb
load font image into a texture
4 files changed,
+33,
-0
+10,
-0
1@@ -0,0 +1,10 @@
2+#ifndef FONT_H
3+#define FONT_H
4+
5+#include "types.h"
6+
7+i8 font_load(const char* path);
8+void font_destroy(void);
9+
10+#endif /* FONT_H */
11+
+1,
-0
1@@ -77,6 +77,7 @@ sources = [
2 'source/world/block.c',
3 'source/world/chunk.c',
4 'source/client/camera.c',
5+ 'source/client/font.c',
6 'source/client/player.c',
7 'source/client/world.c',
8 'source/net/mc_chunk.c',
+19,
-0
1@@ -0,0 +1,19 @@
2+#include "client/font.h"
3+#include "renderer/renderer.h"
4+
5+static MGTexture texture;
6+
7+i8 font_load(const char* path)
8+{
9+ texture = renderer_texture_load(path);
10+ return texture != MGTEXTURE_INVALID;
11+}
12+
13+void font_destroy(void)
14+{
15+ if (texture != MGTEXTURE_INVALID)
16+ renderer_texture_destroy(texture);
17+
18+ texture = MGTEXTURE_INVALID;
19+}
20+
+3,
-0
1@@ -5,6 +5,7 @@
2 #include "mgmath.h"
3 #include "utils.h"
4 #include "client/camera.h"
5+#include "client/font.h"
6 #include "client/player.h"
7 #include "client/world.h"
8 #include "net/mc_chunk.h"
9@@ -125,6 +126,8 @@ static void game_init(int argc, char** argv)
10
11 if (!game.client)
12 create_local_world();
13+
14+ font_load("assets/resourcepacks/1.8.9/assets/minecraft/textures/font/ascii.png");
15 }
16
17 /* run main loop */