Handmade Hero»Forums»Game
10 posts
Ep 190: Why do we use a global debug state?
Edited by Terans on Reason: Initial post
Hi, in episode 190, Casey refactored the debug global variables and the debug code so it only uses a global debug state that is set in GameUpdateAndRender, but why do this, instead of passing the debug state around as needed, so the functions can easily be tested and we know explicitly which variables they use? Is it because it's debug code, so we don't care if it's well written?
497 posts
Ep 190: Why do we use a global debug state?
debug should have minimal overhead, passing a pointer around is overhead, accessing a global is less overhead especially in the functions that aren't logging
Simon Anciaux
1057 posts
Ep 190: Why do we use a global debug state?
Also if you remove the debug stuff from the release build and you were passing the debug state as argument, you might have to change the function signatures or the way you call the functions.