A repository for our first-year C group project at Imperial College London containing:
- A VR voxel game written in C with OpenGL.
- A custom VR headset design (Raspberry Pi 4) along with code to track headset orientation, integrated into the game.
- A custom bluetooth controller design (Raspberry Pi Pico) with code.
The game runs at about 30-35 FPS on the headset (Raspberry Pi 4).
We placed 2nd out of 58 teams and won the "Most Interesting Extension" prize.
IMG_1789.mov
- Procedural terrain generation (infinite world).
- 3D hotbar user-interface.
- Multiple biomes.
- Trees, cacti and igloo structures.
- Vertex lighting.
- Breaking and placing blocks.
- Physics system.
- 3D Audio with miniaudio.
- Render distance-based fog.
- Extremely optimised (frustum culling, meshing algorithms, multi-threading etc).
- Running the game on PC (Windows, Mac, Linux).
- Building the headset and running the game on it (Raspberry Pi 4).
Note: Linux users will need to install the GLFW dependencies separately in order to build, see https://www.glfw.org/docs/3.3/compile.html.
-
Clone this repository and its submodules.
git clone --recursive https://github.com/lxkast/vr-voxel-game.git
-
Build with CMake (use GCC/Clang/MinGW).
cd vr-voxel-game/
cmake -B build
cmake --build build
-
The game executable is found in
./build/game/src
.
Our headset is powered by a Raspberry Pi 4. Below is an overview of the headset's setup.

The ICM-42688 is connected like so:
-
Install the GLFW dependencies, see https://www.glfw.org/docs/3.3/compile.html.
-
Clone this repository:
git clone --recursive https://github.com/lxkast/vr-voxel-game.git
-
Build:
cd vr-voxel-game/
cmake -DBUILD_FOR_RPI=ON -B build
cmake --build build
-
Run:
cd build/game/src
./game
- WASD - movement
- Left Click - mine a block
- Right Click - place a block
- Space - Jump
- Number Keys - select an item in your hotbar
- B - opens 3D hotbar
- P - switches between normal view (one image without distortion) and headset view (two distorted images)
- O - shows the wireframe view of the world
- ESC - quit
Head movement controls where you look and the controller handles everything else.
Below shows what we decided on for our controller:

Should you decide to use your own controller, our program uses 5 buttons from the controller, which are taken as part of an array, as well as an axis input from a joystick. This is how each button is assigned:
- Button 0 - Opens the 3D hotbar
- Button 1 - Mines a block
- Button 2 - Place a block
- Button 3 - Sprinting
- Button 4 - Jump




All code outside of game/external
is our own, with the exception of gl.c
.
All textures are our own.
Audio files are sources from pixabay.com and are used in accordance with their content license.
This repository was migrated from the original GitLab repository owned by the university. Commit messages are prepended with our personal shortcodes for marking purposes.
This project had a 4-week deadline, so we did not have time to make major refactors for any poor architectural decisions. There have been no major changes to the project post-submission.