aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2025-04-09 10:32:36 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2025-04-09 10:32:36 +0200
commit51132aa00ddc4f49bdb1132dc225f56c720e71b8 (patch)
treeb02b78112290050ecb4d6d8351a7b4666d5d2195
parentfd523e10066e91e78e7520407f958c5a228fe80b (diff)
downloadmitjafelicijan.com-51132aa00ddc4f49bdb1132dc225f56c720e71b8.tar.gz
Added new note
-rw-r--r--content/notes/2025-04-08-embedding-game-assets-within-your-binary.md7
-rw-r--r--static/assets/notes/embedding-binary-data.tar.xzbin1222696 -> 1222440 bytes
2 files changed, 6 insertions, 1 deletions
diff --git a/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md b/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md
index bb709bb..65f5813 100644
--- a/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md
+++ b/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md
@@ -93,7 +93,7 @@ CC ?= cc
93CFLAGS := -Wall -Wextra -Wunused -Wno-unused-parameter -Wswitch-enum -Wpedantic -Wno-bitwise-instead-of-logical 93CFLAGS := -Wall -Wextra -Wunused -Wno-unused-parameter -Wswitch-enum -Wpedantic -Wno-bitwise-instead-of-logical
94LDFLAGS := -I./libs -I./libs/raylib-$(RAYLIB_VER)/include ./libs/raylib-$(RAYLIB_VER)/lib/libraylib.a -lm 94LDFLAGS := -I./libs -I./libs/raylib-$(RAYLIB_VER)/include ./libs/raylib-$(RAYLIB_VER)/lib/libraylib.a -lm
95 95
96game: 96game: embed
97 $(CC) $(CFLAGS) -o game main.c $(LDFLAGS) 97 $(CC) $(CFLAGS) -o game main.c $(LDFLAGS)
98 98
99embed: 99embed:
@@ -105,6 +105,9 @@ This converted binary data files into C header style files which contain the
105array of bytes and the size of the array of bytes. This will be useful later 105array of bytes and the size of the array of bytes. This will be useful later
106with raylib code. 106with raylib code.
107 107
108If we execute `make embed` we will create C header files. But running `make
109game` will also call embed as well, so no need to call it separately.
110
108An example of such a file (in our case armor.png) looks like this. 111An example of such a file (in our case armor.png) looks like this.
109 112
110```c 113```c
@@ -190,6 +193,8 @@ get quite big and if that is the problem, you could always compile this into a
190`so` library and include that. This way you could create data packs for audio, 193`so` library and include that. This way you could create data packs for audio,
191graphics, etc. and ship that alongside your game binary. 194graphics, etc. and ship that alongside your game binary.
192 195
196Run `make -B game` and run the game.
197
193![Basic window](/assets/notes/embedding-assets.png) 198![Basic window](/assets/notes/embedding-assets.png)
194 199
195## Honorable mention: C23-embed-directive 200## Honorable mention: C23-embed-directive
diff --git a/static/assets/notes/embedding-binary-data.tar.xz b/static/assets/notes/embedding-binary-data.tar.xz
index 15e3ff4..8c88286 100644
--- a/static/assets/notes/embedding-binary-data.tar.xz
+++ b/static/assets/notes/embedding-binary-data.tar.xz
Binary files differ