Register
Handmade Hero»Forums»Game»Ep 190: Why do we use a global debug state?
2 posts
Ep 190: Why do we use a global debug state?
1 month ago Edited by Terans on Nov. 2, 2020, 9:55 p.m. 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?
488 posts
Ep 190: Why do we use a global debug state?
1 month ago
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
920 posts
Ep 190: Why do we use a global debug state?
1 month ago
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.