7 ms·
More of a general nooby question: what would be a good way to read through code like this? Where to start? How to understand what's going on and when? etc.
by ne0flex 3y ago
More of a general nooby question: what would be a good way to read through code like this? Where to start? How to understand what's going on and when? etc.
- mknsri 3y agoIt depends a little bit on how comfortable you are with the platform and the technologies used in the codebase. Generally speaking you would look for the entrypoint into the application. For Hockey Slam you can look for the entrypoint in Windows: https://github.com/Mknsri/HockeySlam/blob/main/windows/win_main.cpp#L897 https://github.com/Mknsri/HockeySlam/blob/main/windows/win_m... or Android: https://github.com/Mknsri/HockeySlam/blob/main/android/app/src/main/cpp/game-activity.cpp#L450 https://github.com/Mknsri/HockeySlam/blob/main/android/app/s... Then start tracing through, looking at any function calls that look like they contain anything interesting. Additionally in this project you can jump straight to the entrypoints of the game code: https://github.com/Mknsri/HockeySlam/blob/main/game/game_main.cpp#L36 https://github.com/Mknsri/HockeySlam/blob/main/game/game_mai... Or the rendering code: https://github.com/Mknsri/HockeySlam/blob/main/ogl/ogl_main.cpp#L868 https://github.com/Mknsri/HockeySlam/blob/main/ogl/ogl_main.... Another way would be to look at the files and see if anything catches your interest, for example if you want to learn about the UI system, you could look at how a button is defined: https://github.com/Mknsri/HockeySlam/blob/main/game/imui_system.cpp#L98 https://github.com/Mknsri/HockeySlam/blob/main/game/imui_sys... Fabien Sanglard has great articles on studying classic video game engines, and could be used as a guide on how to approach codebases: https://fabiensanglard.net/quake2/index.php https://fabiensanglard.net/quake2/index.php
- ne0flex 3y agoThank you very much! I appreciate you taking the time to provide these resources.