This project uses GPU to evaluate cellular automata of Conway's Game of Life. The calculations of the next generaion of the cellular autamata are made with the fragment shader and the evaluation result is caught with frame buffers.
Generating build files for your OS and build system requires CMake. Most of the dependencies are bundled with the repository as git submodules. This includes:
- glad - OpenGL Function Loader.
- glfw - Windowing and Input.
- plog - Logging library.
- imgui - UI library.
- HandmadeMath - Vector algebra.
The following instructions apply to:
- Ubuntu 20.04, 18.04, 16.04
- Debian 9 and higher
sudo apt-get install -y \
build-essential \
cmake \
xorg-dev \
libgl1-mesa-dev \
libfreetype6-dev
The following instructions apply to:
- Fedora 22 and higher
sudo dnf install -y \
gcc gcc-c++ make \
cmake \
mesa-libGL-devel \
libXrandr-devel \
libXinerama-devel \
libXcursor-devel \
libXi-devel \
freetype-devel
- CentOS 7 and higher
sudo yum install -y \
gcc gcc-c++ make \
cmake \
mesa-libGL-devel \
libXrandr-devel \
libXinerama-devel \
libXcursor-devel \
libXi-devel \
freetype-devel
git clone --recursive https://github.com/Postrediori/GameOfLifeGpu.git
cd GameOfLifeGpu
Cloning the repository requires passing the --recursive
flag to load Git submodules.
The program is built with the commands below. CMake requires the directory
with the main project's CMakeLists.txt
file as an argument. Then the CMake
creates the build files for the GNU make which build an executable.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
make install
After the successful build the binary GameOfLifeGpu
will end up in <source dir>/bundle
.
You’ll need to download and install the following to build the project:
- Xcode and the Xcode command line tools
- CMake (e.g. via homebrew
brew install cmake
)
git clone --recursive https://github.com/Postrediori/GameOfLifeGpu.git
cd GameOfLifeGpu
Generate makefiles for the build:
mkdir build && cd build
cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE=Release
make
make install
An GameOfLifeGpu
application bundle will now be present under <Source directory>/bundle
.
- F1 – Toggle fullscreen mode.
- RMB and Space – Restart simulation.
- 1..4 – Change model size (and restart simulation).
The FPS are often limited to the displays vertical refresh rate (i.e. 60 fps).
In order to render generations as fast as possible on 3D-accelerated hardware adjust the vblank_mode
environment variable:
vblank_mode=0 ./GameOfLife
- Build instructions
- Optimization of generation algorithm (mark cells that were changed or may be changed)
- Capture screenshots&animation
- Edit cellular automata rules
- Cellular automata with more cell states (e.g. predator-pray)