To get started with Tetra, you'll need a couple of things installed:
- The latest stable version of Rust
- The SDL 2.0 development libraries
- The ALSA development libraries (only required on Linux)
# Installing Rust
Installing Rust is pretty simple - just go to the website and download the Rustup toolchain manager.
Note that if you're developing on Windows with the default toolchain, you'll also need to install the Microsoft Visual C++ Build Tools, as Rust uses the MSVC linker when building.
# Installing SDL 2.0
Tetra uses SDL for windowing and input, so you will need to have both the runtime and development libraries installed.
The instructions below are adapted from the README of the sdl2 crate - further information can be found there.
If you're using the default MSVC Rust toolchain:
- Go to the SDL website and download the Visual C++ version of the development libraries.
- Copy the
.libfiles from the
SDL2-2.0.x/lib/x64folder of the zip to the
%USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/libfolder on your machine. If you are building on a beta/nightly toolchain, adjust the location accordingly.
If you're using the GNU-based Rust toolchain:
- Go to the SDL website and download the MinGW version of the development libraries.
- Copy the
.libfiles from the
SDL2-2.0.x/x86_64-w64-mingw32/libfolder of the zip to the
%USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/libfolder on your machine. If you are building on a beta/nightly toolchain, adjust the location accordingly.
When starting a new Tetra project, you will also need to make sure that SDL2.dll is present in the root of your project (i.e. the directory where you
cargo run). You will also need to provide it alongside your game's executable when distributing it to players. Your game will not start if it is missing!
You can download SDL2.dll from the 'Runtime Binaries' section of the SDL website - pick the version that corresponds to your system architecture.
The easiest way to install SDL is via Homebrew:
brew install sdl2
You will also need to add the following to your
~/.bash_profile, if it is not already present.
If you're building your game on Catalina, make sure that you use SDL 2.0.12 or higher - there is a bug in earlier versions which causes the OpenGL viewport to not scale correctly. See issue #147 for more information.
The SDL development libraries are distributed through most Linux package managers - here are a few examples:
# Ubuntu/Debian sudo apt install libsdl2-dev # Fedora/CentOS sudo yum install SDL2-devel # Arch Linux sudo pacman -S sdl2
# Installing ALSA (Linux only)
On Linux, ALSA is used as the audio backend, so you will also need the ALSA development libraries installed. Similar to SDL, you can find these libraries on most Linux package managers:
# Ubuntu/Debian sudo apt install libasound2-dev # Fedora/CentOS sudo yum install alsa-lib-devel # Arch Linux sudo pacman -S alsa-lib