Skip to content

Postrediori/GameOfLifeGpu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life on GPU using OpenGL

Introduction

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.

Screenshots

Screenshot on Windows Screenshot on Windows Screenshot on macOS

Dependencies

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:

Building for Linux

Dependencies

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

Cloning Repository

git clone --recursive https://github.com/Postrediori/GameOfLifeGpu.git
cd GameOfLifeGpu

Cloning the repository requires passing the --recursive flag to load Git submodules.

Building Project

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.

Building for macOS

Dependencies

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)

Cloning Repository

git clone --recursive https://github.com/Postrediori/GameOfLifeGpu.git
cd GameOfLifeGpu

Using Building

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.

Controls

  • F1 – Toggle fullscreen mode.
  • RMB and Space – Restart simulation.
  • 1..4 – Change model size (and restart simulation).

Tips

Disable vertical sync

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

Links

TODO

  • 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)