# Raspberry Pi 2 Notes

### Requirements

- Raspbian Jessie or later
- CMake 3.0+
- Clang 3.5.0+

#### CMake

To install CMake:

    sudo apt-get install cmake

#### Clang

Cinder should be built using the version of Clang (v3.5.0) packaged for Raspbian Jessie. Install it using `apt-get`:

    sudo apt-get install clang

You can also download the binaries for Clang from here. For the Raspberry Pi 2, download Clang for armv7a Linux.

To set Clang as the default compiler, select `/usr/bin/clang++` when prompted by this command:

    sudo update-alternatives --config c++

If you have special reason to use GCC instead of Clang, the CPU/GPU memory split will need to be adjusted. The default settings for the memory split causes a hard crash when building Cinder. Please see the Raspberry Pi 2 documentation for instructions.

NOTE: Cinder has not been tested using GCC 5.x on Raspberry Pi 2.

### Cinder Dependencies

    sudo apt-get install libxcursor-dev \
    libgles2-mesa-dev \
    zlib1g-dev \
    libfontconfig1-dev \
    libmpg123-dev \
    libsndfile1 \
    libsndfile1-dev \
    libpulse-dev \
    libasound2-dev \
    libcurl4-gnutls-dev \
    libgstreamer1.0-dev \
    libgstreamer-plugins-bad1.0-dev \
    libgstreamer-plugins-base1.0-dev \
    gstreamer1.0-libav \
    gstreamer1.0-alsa \
    gstreamer1.0-pulseaudio \
    gstreamer1.0-plugins-bad

# Building Cinder

### Fetching and Building Cinder

    git clone --recursive https://github.com/cinder/Cinder.git
    cd Cinder
    mkdir build && cd build
    cmake .. -DCINDER_TARGET_GL=es2-rpi
    make -j 3

# Building and Running BasicApp

### Building

    cd samples/BasicApp/proj/cmake
    mkdir build && cd build
    cmake .. -DCINDER_TARGET_GL=es2-rpi
    make

### Running

Starting from `samples/BasicApp/proj/cmake/build`:

    ./Debug/BasicApp

### Exiting

Hit the `Esc` key to exit the BasicApp. Cinder for Linux on the Raspberry Pi 2 currently has `Esc` hardcoded to exit an application. Otherwise it's non-trivial to return to the OS. A future version will offer a more graceful way to handle this.

# Troubleshooting

### Audio

#### Starting the pulsedeamon

Raspbian ships with Pulse Audio installed, however you must start the `pulsedeamon` before you can use audio in your application. Do that by running the following:

    pulseaudio -D

#### No Output Using 3.5mm headphone jack

Try the following, it will force output to the 3.5mm jack (more information here):

    sudo amixer cset numid=3 1