This is a C++ 3D voxel game prototype with modular architecture: window management, input handling, 2D/3D rendering, camera control, block system with frustum culling, and debug overlay.
B-Lec/
├── include/ # Header files
│ ├── window/ # Window management
│ ├── input/ # Input handling
│ ├── render/ # Rendering, fonts, camera, and mesh
│ ├── world/ # Block system and frustum culling
│ └── debug/ # Debug overlay
├── src/ # Implementation files
│ ├── window/
│ ├── input/
│ ├── render/ # Includes camera.cpp and mesh.cpp
│ ├── world/ # Includes block_system.cpp
│ ├── debug/
│ └── main.cpp # Entry point
├── code_testing/ # Unit tests
│ ├── test_framework.h
│ ├── window/
│ ├── input/
│ ├── render/
│ ├── world/
│ └── debug/
└── CMakeLists.txt # Build configuration
- CMake 3.20+
- C++17 compiler (MSVC, GCC, or Clang)
- Internet access for first configure (GLFW and GLM are fetched by CMake)
- OpenGL 2.1 or higher (for 3D rendering)
The project uses FetchContent to automatically download dependencies:
- GLFW 3.4: Window creation and input management
- GLM 0.9.9.8: Mathematics library for 3D transformations (header-only)
Both are downloaded automatically during the first CMake configure.
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 ..
cmake --build . --config ReleaseRun:
.\bin\Release\blec.exemkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallelRun:
./bin/blecAdd -DBUILD_TESTS=ON to the cmake configuration command:
cmake -G "Visual Studio 17 2022" -A x64 -DBUILD_TESTS=ON ..
cmake --build . --config Releasecmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON ..
cmake --build . --parallelRun tests:
cmake --build build --target run_testsSee code_testing/README.md for detailed testing information.
- F12: Toggle debug overlay
- ESC: Toggle pause menu (unlocks mouse, shows Resume/Quit buttons)
- W: Move forward
- S: Move backward
- A: Strafe left
- D: Strafe right
- SPACE: Move up
- CTRL: Move down
- MOUSE: Look around (move mouse to rotate camera view)
Manages GLFW window creation, lifecycle, and properties. Cross-platform window management with OpenGL context.
Handles keyboard and mouse input tracking, with callbacks and state queries. Includes mouse look delta for camera control.
Provides 2D and 3D rendering operations:
Renderer: 2D drawing primitives, 3D matrix setup, and OpenGL state managementBitmapFont: 5x7 pixel font rendering for text displayCamera: Free-flying 3D camera with WASD movement and mouse look (yaw/pitch rotation)Mesh: 3D geometry storage and rendering with back-face culling
Manages the voxel game world and optimization:
BlockSystem: 3D voxel grid with block storage and queries- Frustum Culling: Automatically determines which blocks are visible in the camera's view to optimize rendering
- Configurable grid dimensions and block sizes
Manages user interface and game state:
UIManager: Crosshair, pause menu, and mouse lock management- Crosshair: Always-visible crosshair in screen center for aiming
- Pause Menu: ESC-toggleable menu with Resume and Quit buttons
- Mouse Lock: Automatic cursor locking during gameplay for seamless camera control
Displays comprehensive real-time debug information including:
- FPS and performance metrics
- Camera position and orientation
- Block counts (total and visible in frustum)
- Input state and error tracking