diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-04-09 10:32:36 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-04-09 10:32:36 +0200 |
| commit | 51132aa00ddc4f49bdb1132dc225f56c720e71b8 (patch) | |
| tree | b02b78112290050ecb4d6d8351a7b4666d5d2195 /content/notes | |
| parent | fd523e10066e91e78e7520407f958c5a228fe80b (diff) | |
| download | mitjafelicijan.com-51132aa00ddc4f49bdb1132dc225f56c720e71b8.tar.gz | |
Added new note
Diffstat (limited to 'content/notes')
| -rw-r--r-- | content/notes/2025-04-08-embedding-game-assets-within-your-binary.md | 7 |
1 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 | |||
| 93 | CFLAGS := -Wall -Wextra -Wunused -Wno-unused-parameter -Wswitch-enum -Wpedantic -Wno-bitwise-instead-of-logical | 93 | CFLAGS := -Wall -Wextra -Wunused -Wno-unused-parameter -Wswitch-enum -Wpedantic -Wno-bitwise-instead-of-logical |
| 94 | LDFLAGS := -I./libs -I./libs/raylib-$(RAYLIB_VER)/include ./libs/raylib-$(RAYLIB_VER)/lib/libraylib.a -lm | 94 | LDFLAGS := -I./libs -I./libs/raylib-$(RAYLIB_VER)/include ./libs/raylib-$(RAYLIB_VER)/lib/libraylib.a -lm |
| 95 | 95 | ||
| 96 | game: | 96 | game: embed |
| 97 | $(CC) $(CFLAGS) -o game main.c $(LDFLAGS) | 97 | $(CC) $(CFLAGS) -o game main.c $(LDFLAGS) |
| 98 | 98 | ||
| 99 | embed: | 99 | embed: |
| @@ -105,6 +105,9 @@ This converted binary data files into C header style files which contain the | |||
| 105 | array of bytes and the size of the array of bytes. This will be useful later | 105 | array of bytes and the size of the array of bytes. This will be useful later |
| 106 | with raylib code. | 106 | with raylib code. |
| 107 | 107 | ||
| 108 | If we execute `make embed` we will create C header files. But running `make | ||
| 109 | game` will also call embed as well, so no need to call it separately. | ||
| 110 | |||
| 108 | An example of such a file (in our case armor.png) looks like this. | 111 | An 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, |
| 191 | graphics, etc. and ship that alongside your game binary. | 194 | graphics, etc. and ship that alongside your game binary. |
| 192 | 195 | ||
| 196 | Run `make -B game` and run the game. | ||
| 197 | |||
| 193 |  | 198 |  |
| 194 | 199 | ||
| 195 | ## Honorable mention: C23-embed-directive | 200 | ## Honorable mention: C23-embed-directive |
