raylibd hot-reloads c raylib programs
Get ghc-9.6.7 and cabal-install 3.14.1.1 or similar from https://www.haskell.org/ghcup/install/
git clone https://github.com/aavogt/raylibd
cd raylibd
cabal install
raylibd init my_app -i 10 # use example init/10-*
cd my_app
make -j12 # downloads raygui&raylib (if missing) into vendor/raylib/, and runs main_hot
The my_app is then a minimal fragment shader example:
my_app
├── 10-tint.fs
├── compile_commands.json # for clangd
├── dll.c
├── dll.so
├── main.c
├── main_hot
├── main_hot.c
├── Makefile
└── vendor
├── Makefile
└── raygui.h
The default make watch target calls
raylibd to turn main.c into dll.c. main_hot loads the dll.so which
knows how to reload assets (including shaders), and to migrate state.
Save changes to main.c or 10-tint.fs and you should be able to see the effects right away.
-
emscripten output option wip/gregg-board/filament/main.c it's not much
-
remove unused original variable declarations copied into dll.c
-
#line pragmas
-
nested arrays could reuse more space?
struct state { int nframe; int n; int m; int x; int xs[12][2];
}; struct prevstate { int nframe; int n; int m; int x; int dummy0[12][2]; int dummy1[13][2]; int xs[14][2];
};
-
nix build .#wasm; cd result/www; emrun myapp.htmlworks but maybeMakefiles could work inside nix shell nix develop etc. -
LoadFontEx, LoadAudioStream take extra arguments to be stored in AssetSlot
-
rewriteAssetLoads is wrong with
Shader sh[2] = { LoadShader(vs, fs); } ; -
hpc coverage
-
integration tests
-
deleted structs are used but not defined in the generated code
-
moving code to a #include "foo.inc" breaks the build/recompilation checking suggest/do
rm dll.c && make -
raylibd init\ntic\npicks turing.c not tictagtoe.c, so drop .d or change the cost of inserts to depend on in/out
-
wip/emscripten-soa creates functions to mmap csv files, it doesn't quite seem right to have to edit the makefile?
dll.so: dll.c sed -e '/^void Init.*{/ s/$$/;mmap_data_points();/' -e '/^void Reinit.*{/ s/$$/;mmap_data_points();/' < $^ > dll2.c $(CC) $(CFLAGS) -DRL_SO_IMPL -shared -o dll.so.2 dll2.c mv dll.so.2 $@ -
name anonymous structs
dll.c: In function ‘ReinitAlloc’: dll.c:284:19: error: incompatible types when assigning to type ‘struct <anonymous>’ from type ‘struct <anonymous>’ 284 | t->entities = s->entities; struct { float x[NSTORE]; float *y, *z; } store; vs the workaround: typedef struct { float x[NSTORE]; } Store; Store store; -
float x[2*3] is treated differently than x[6]