How evan-ciao/garden-opengl works
Project type and overall purpose
• This is a small, learning-oriented 3D graphics/demo application written in C++ using OpenGL 1.3.
• It uses SDL for windowing and input, SOIL for texture loading, and some Irrlicht headers for math utilities.
• Core functionality: initialize graphics context, load models/textures, enter game loop, process input & physics (sphere collisions), then render the scene.
File structure to extract major components
• Root headers (playerEntity.hpp, gameObject.hpp, mesh.hpp, rigidbody.hpp, world.hpp, camera.hpp, renderer.hpp, collider.hpp) define the in-engine components.
• main.cpp – the entry point, sets up SDL/OpenGL, drives the game loop.
• data/ and models/ folders – store raw assets (bitmaps, .obj meshes, model-specific headers and Python scripts).
• /SDL, include/SOIL, include/irrlicht – third-party libraries compiled into lib/libSDL*.a and lib/libSOIL.a.
• Makefile.win – build script (Windows), .gitignore – ignores build artifacts.
Extract architectural insights from the README
• “playerEntity” handles input callbacks, updates camera and position.
• “world” manages all game objects, performs collision checks every frame.
• Physics is limited to a sphere-vs-mesh “Collide and Slide” algorithm in world.hpp and collider.hpp.
a. Application Launcher (main.cpp)
b. Window & Context (SDL → OpenGL)
c. Input Subsystem (SDL event loop → playerEntity)
d. Game World
• Entity Manager (world.hpp)
• GameObject (gameObject.hpp) + Components
– Transform
– Mesh Component (mesh.hpp)
– Rigidbody Component (rigidbody.hpp)
– Collider (collider.hpp)
e. Physics & Collision
• Collision Handler (world + collider)
f. Camera (camera.hpp)
g. Rendering Pipeline (renderer.hpp)
• Shader-less fixed-function OpenGL 1.3
• Asset Loader (SOIL for textures, custom .obj loader in mesh)
h. Data Storage (models/, data/)
i. External Libraries (SDL, SOIL, Irrlicht math)
j. GPU / Display
Relationships & data flow
• main.cpp initializes SDL & OpenGL → loads assets via mesh/renderer.
• enters Game Loop:
1) Poll SDL events → dispatch to playerEntity (input subsystem).
2) playerEntity updates Camera and player’s GameObject transform.
3) world.update():
• For each GameObject with Rigidbody & Collider, test sphere-mesh collisions.
• Resolve positions.
4) renderer.render():
• For each GameObject with Mesh, submit vertex data + texture to OpenGL.
• Asset Loader reads from disk (models/, data/) once at startup.
• External libs provide windowing, input, image loading, math support.
Architectural patterns & design principles
• Component-based entity system (GameObject + pluggable components).
• Single main loop orchestrating subsystems (input → physics → render).
• Separation of concerns: input logic in playerEntity, collision in world/collider, rendering in renderer.
• Header-only style (to avoid linking hassles), minimal dependencies.