Voxel Terrain Explorer
Build a voxel terrain explorer in C++, a small Minecraft-like world viewer: terrain is generated from noise as a grid of blocks (grass, dirt, stone, water and snow), split into chunks of 16×16×128 blocks, turned into meshes that only include visible faces, and drawn with OpenGL, while you fly around with the mouse and keyboard. Chunks are generated and loaded around the camera as you move and unloaded behind you, and modified chunks are saved to disk. It runs on desktop (it can later be ported to mobile). You'll learn 3D rendering basics with OpenGL, GLFW for windows and input, camera math with GLM, procedural generation with noise, building efficient meshes, chunk streaming, and profiling.
- Estimate
- ~14.5h
- Steps
- 7
- Completed by
- 0
- Proposed by
- codeseed.app
CMake · OpenGL · GLFW · GLM · FastNoiseLite
Project roadmap
- 01
Open a window and draw a cube
~2.5hSet up a CMake project with GLFW, glad (for OpenGL loading), GLM and a noise library (such as FastNoiseLite, a single header). Open a window, compile a simple vertex and fragment shader, and draw one colored cube with a model, view and projection matrix. Done when: a rotating cube appears in the window.
- 02
Add a flying camera
~1.5hWrite a camera with position, yaw and pitch, controlled by WASD to move, the mouse to look around (with the cursor captured), and Space and Shift to go up and down, with movement scaled by frame time so speed doesn't depend on the frame rate. Done when: you can fly smoothly around the cube.
- 03
Generate chunks of terrain
~2hDefine a Chunk (16×16×128 block types in a flat array) and generate it from 2D noise for the height (with several octaves) plus rules for block types (water below sea level, sand near it, grass on top, stone below and snow on high ground), using the world seed. Done when: generating a chunk gives sensible block types, and the same seed gives the same chunk.
- 04
Build meshes with only visible faces
~2.5hBuild a mesh for each chunk that only includes block faces touching air (checking neighboring chunks at the edges), with a color or texture coordinates per block type and simple lighting from the face direction. Upload it to a vertex buffer, and rebuild it only when the chunk changes. Show the number of triangles drawn. Done when: a chunk renders with far fewer triangles than drawing every cube.
- 05
Load chunks around the camera
~2.5hKeep chunks within a view distance of the camera loaded, generating new ones as you move (on a background thread, uploading the mesh on the main thread, since OpenGL calls must happen there) and unloading far ones. Skip drawing chunks outside the camera's view (frustum culling). Done when: flying in one direction keeps showing new terrain at a steady frame rate.
- 06
Edit and save the world
~2hLet the player remove and place blocks by clicking (casting a ray from the camera through the voxel grid), rebuilding the affected chunk meshes. Save modified chunks to files (a simple binary format per chunk, written atomically, with Boost for file handling if you like) and load them instead of generating when they exist. Done when: changes to the world are still there after restarting.
- 07
Profile and test
~1.5hMeasure frame time and chunk generation time, and record them in README.md with the view distance. Write unit tests (with Catch2 or doctest) for chunk generation determinism, face visibility rules at chunk edges, and saving and loading chunks. Done when: the tests pass, and README.md shows the performance numbers.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack