3 ms·
So does the good old Quake 2 rendering API. The game exported a bunch of functions to the renderer via refimport_t and the renderer in return provided functions
by dividuum 2y ago
So does the good old Quake 2 rendering API. The game exported a bunch of functions to the renderer via refimport_t and the renderer in return provided functions via refexport_t. The only visible symbol in a rendering DLL is GetRefAPI_t: https://github.com/id-Software/Quake-2/blob/master/client/ref.h#L224 https://github.com/id-Software/Quake-2/blob/master/client/re...
I remember being impressed by this approach, so I shamelessly copied it for my programming game: https://github.com/dividuum/infon/blob/master/renderer.h https://github.com/dividuum/infon/blob/master/renderer.h :)
- dfox 2y agoI somehow suspect that the reason why Quake2 does this lies in the legacy of Quake1 written in DJGPP. DJGPP supports dynamicaly loaded libraries (although the API is technically unsupported and internal-only), but does not have any kind of dynamic linker, thus passing around pair of such structs during library initialization is the only way to make that work.
- jamesfinlayson 2y agoPretty sure Half-Life does something pretty similar - all functionality between the game and engine is done via function pointer structs.
- MisterTea 2y agoThe original Half-Life engine, now called Goldsrc, is a heavily modified Quake engine with bits of Quake 2 in there.
- immibis 2y agoThis is cargo cult. You can just directly export and import the rendering functions.