[HN Gopher] Hot Reload Gameplay Code
___________________________________________________________________
Hot Reload Gameplay Code
Author : dsego
Score : 8 points
Date : 2024-12-18 17:03 UTC (5 hours ago)
(HTM) web link (zylinski.se)
(TXT) w3m dump (zylinski.se)
| chrisjj wrote:
| > This can be fixed by only using global variables that are
| pointers to fields within GameMemory. When a hot reload occurs
| and game_hot_reloaded is run, you can then reassign those global
| pointers to the correct memory inside the GameMemory struct.
|
| This being manual sounds like a recipe for bugs. Can it not be
| automated?
| flysand7 wrote:
| > The answer is that the Raylib DLL is implicitly pulled in by
| game.dll, but unloading game.dll does not unload the implicitly
| pulled in Raylib DLL
|
| Was about to comment on this one, this only applies on Windows.
| So far as my experimentation with Hot Reloading with Odin on
| Linux went though, on linux that would work differently. It
| seemed as though there was some kind of reference counter on
| shared objects, so if your main exe didn't use raylib, it would
| also get yeeted when you unload the game and all of the state
| would reset.
|
| So if you really want to make this work on both windows and
| linux, you'd insert @require import
| "vendor:raylib" _ :: raylib
|
| In the main program and iirc you don't have to do anything else.
| Actually it was like a year ago the last time I did this, I don't
| remember what the issue was haha. Pretty sure I ran into a bug
| with GLFW thread locals but yea. no idea.
___________________________________________________________________
(page generated 2024-12-18 23:01 UTC)