RE: https://mastodon.gamedev.place/@eniko/116294846594582444
I like that this is made in C in a platform agnostic manner so theoretically it could be ported to pretty much anything
RE: https://mastodon.gamedev.place/@eniko/116294846594582444
I like that this is made in C in a platform agnostic manner so theoretically it could be ported to pretty much anything
@eniko ah finally
not doom
@eniko
Nokia N-Gauge!? 😮
(J/k)
@eniko Hi! I find platform-agnostic C really cute too! I ported a toy node-based expression language from SDL to wasm and it was a breeze!
I'm curious how you architected your code, I'm guessing there is a host which contains the entrypoint and libraries, and a guest which is a zero-dependency library, and you link those together? (if not, what did you do?)
How do you handle control flow? Is the main loop in the host or the guest?
(Or both, like with message passing?)
I'm asking because I started following this style last year, but I'm pretty clueless as to how others do it. I tend to put the main loop on the host, have a tick and a render function on the guest. I haven't had to deal with audio nor complex rendering pipeline setups yet.
Sorry if this is overwhelming! (feel free not to answer!)
@eniko A really cool side effect of this separation is that you can compile the guest code into a dynamic library for dev builds and implement hot reloading in the host :D
This requires architecting the code to never store pointers, and it's not possible to hot-reload memory layout changes, but it's still reeallyy satisfying to work in real time in C. It's almost uncanny when you're used to recompiling and rerunning the program by hand.
@eniko @vchakhno I worked on a engine once that did similar in a multi platform environment. I suppose you could think of it as link-time polymorphism. To modify your example:
system.h
system_pc.c
system_xbox.c
system_ps.c
Every platform used the .h file, but only the relevant platform compiled+linked its corresponding .c file
Worked pretty well