A Minecraft-like voxel engine built from scratch in C++20 with OpenGL 4.5+. Features include infinite world streaming, chunk-based world management, greedy meshing, multithreaded generation, and frustum culling for optimal performance.
- High Performance: Designed for maximizing performance
- Infinite World: Chunk-based streaming with configurable render distance
- Greedy Meshing: Optimized mesh generation reducing vertex count
- Multithreading: Asynchronous chunk generation and mesh building
- Modern OpenGL: Uses OpenGL 4.5+ with persistent mapped buffers
- Frustum Culling: Only renders visible chunks
- FPS Camera: Smooth WASD + mouse control with flight mode
- Block Interaction: Place and break blocks with raycasting
- Water Rendering: Transparent animated water with wave effects
- Day/Night Cycle: Dynamic lighting with sunrise/sunset transitions
- Player Physics: Gravity, collision detection, and water physics
- C++20 compatible compiler (GCC 10+, Clang 12+, MSVC 2019+)
- CMake 3.15+
- OpenGL 4.5+ capable GPU
The project uses:
- GLFW - Window and input management
- GLM - Mathematics library
- GLAD - OpenGL loader
Dependencies are automatically fetched via CMake FetchContent if not found on the system.
First, you need to generate GLAD files. Visit https://glad.dav1d.de/ and generate with:
- Language: C/C++
- Specification: OpenGL
- API gl: Version 4.5 (or higher)
- Profile: Core
- Generate a loader: YES
Extract the generated files to:
external/glad/
├── include/
│ ├── glad/
│ │ └── glad.h
│ └── KHR/
│ └── khrplatform.h
└── src/
└── glad.c
Or use this quick command (requires Python and pip):
pip install glad
python -m glad --generator=c --out-path=external/glad --profile=core --api="gl=4.5"mkdir build
cd build
cmake ..
cmake --build ../bin/minecraft_cpp- W/A/S/D - Move forward/left/backward/right
- Space - Move up (double-tap to toggle flight mode)
- Left Shift - Move down
- Mouse - Look around
- Left Click - Break block
- Right Click - Place block
- ESC - Open/close menu
- Q - Exit (from menu)
minecraft-cpp/
├── src/
│ ├── Core/ # Core utilities (Window, Time, Logger, ThreadPool)
│ ├── Math/ # Math utilities (Ray)
│ ├── World/ # World system (Block, Chunk, ChunkManager, WorldGenerator)
│ ├── Mesh/ # Mesh system (Vertex, MeshBuilder, Mesh)
│ ├── Render/ # Rendering (Shader, Camera, Renderer, Frustum, GPUBufferAllocator)
│ ├── Util/ # Configuration and types
│ └── main.cpp # Application entry point
├── shaders/ # GLSL shaders
├── assets/ # Textures and resources
├── external/ # External dependencies (GLAD)
└── CMakeLists.txt
UNLOADED → GENERATING → MESH_BUILD → READY → GPU_UPLOADED
- Main thread: Rendering and input
- Worker threads: Chunk generation and mesh building
- Lock-free queues for communication
- Frustum culling removes invisible chunks
- Visible chunks rendered with instanced drawing
- Greedy meshing minimizes draw calls
- Persistent mapped buffers for zero-copy GPU uploads
Edit src/Util/Config.h to customize:
- Chunk size and render distance
- Thread pool size
- Camera settings
- World generation parameters
- Greedy meshing reduces vertices by ~70%
- Frustum culling skips off-screen chunks
- Multithreading prevents main-thread stalls
- Persistent buffers minimize GPU synchronization
- Block placement/destruction
- Advanced LOD system
- Biomes and caves
- Water rendering with transparency
- Lighting system (Ambient Occlusion)
- Save/load world data
- Player physics and collision
- Multiplayer support
See LICENSE file for details.
Built as a learning project to explore:
- Modern C++ (C++20)
- OpenGL 4.5+ features
- Game engine architecture
- Voxel rendering techniques









