How nrednav/game-engine works
Main Components
a. External Dependencies & Build System:
• That CMake, Makefile, and supporting files (e.g., CMakeLists.txt) are used to build the project.
• External libraries: OpenGL, GLFW3, GLEW, GLM.
b. Core Engine Modules:
• Module: (src/Display) – Responsible for window/context creation and managing the display.
• Entity System: (src/Entity) – Contains components like Camera, Entity, EntityManager, Light, and Player. This module is key for managing scene objects and gameplay entities.
• Loader Module: (src/Loader) – Handles asset loading including OBJ files (ObjLoader) and other resources.
• Model & Texture Handling: (src/Model, src/Texture) – Manages raw and textured models, as well as terrain textures and texture packs.
• Shader Management: (src/Shader) – Manages shader programs for various components (entities, terrain) and holds shader source files.
• Specialized Components:
▫ Skybox: (src/Skybox) – Manages the skybox with its dedicated renderer and shaders.
▫ Terrain & Floor: (src/Terrain, src/Floor) – Responsible for constructing the ground and environment.
• Utility/Math: (src/Utils) – Contains helper functions for mathematical operations and random number generation.
Relationships and Data Flow
• The Display component initializes the OpenGL context. Once set up, the Engine enters its main loop (starting from Main.cpp in src/).
• The Loader reads asset files (models, textures) from the assets folder and passes them to the Model and Texture modules.
• The Entity Manager creates and updates game entities (including players and cameras) and organizes them for rendering.
• The Renderer components (MasterRenderer, EntityRenderer, TerrainRenderer, SkyboxRenderer) receive data from the Entity System and Model/Texture modules, then apply the appropriate shaders (managed by the Shader module) to render the scene.
• The Shader module compiles and configures shader programs that are used by the rendering routines.
• The Utility module supports various other modules with math functions and random number generation essential for transformations and physics.
• The build system (CMake/Makefile) ties all these components together for building and deployment.
Architectural Patterns and Principles
• Modularity: Each major function (display management, asset loading, rendering, etc.) is broken into distinct modules.
• Separation of Concerns: Rendering, logic (entity handling), resource loading, and shader management are kept in separate directories.
• Pipeline Design: There is a clear rendering pipeline where assets are loaded → entities are created/managed → shaders are applied → final rendering occurs.
• Abstraction: Specific implementations like ObjLoader abstract away file parsing details.