Generative Graphics with openFrameworks on the Raspberry Pi – Course / 4 sessions / Fab Lab Berlin – Session 1



Generative Graphics with openFrameworks on the Raspberry Pi – Course / 4 sessions / Fab Lab Berlin – Session 1

2 2


generative-graphics-with-of-on-rpi

Main slideshow for the Generative Graphics with openFrameworks on the Raspberry Pi workshop

On Github kr15h / generative-graphics-with-of-on-rpi

Generative Graphics with openFrameworks on the Raspberry Pi

Course / 4 sessions / Fab Lab Berlin

by Krisjanis Rijnieks

Overview

  • Session 1 (20.03): RPi Setup
  • Session 2 (27.03): openFrameworks intro
  • Session 3 (17.04): Advanced examples
  • Session 4 (24.04): Individual Projects

About me

  • Krisjanis Rijnieks
  • krisjanis.rijnieks@gmail.com
  • http://rijnieks.lv

Session 1

RPi Setup

Requirements

  • Raspberry Pi model B
  • Charger 5V 1-2A with Micro USB B
  • At least 4 GB SD card
  • SD card reader
  • Ethernet cable
  • Raspbian image file
  • Follow the instructions hereto set up your Raspberry Pi

Session 2

openFrameworks intro

Install openFrameworks

Follow the instructions available here to install openFrameworks on the Raspberry Pi.

Get a text editor

If you don't have your favorite text editor yet, download Sublime Text - it is available for Mac, Linux and Windows

It looks and works the same way in all three platforms.

Download examples

There is a Git repository here. Click on Download ZIP or clone it with Git if you have it installed by using the following commands in the Terminal:

cd /Users/your/workshop/directory
git clone https://github.com/kr15h/rpi-of-workshop-examples.git
cd rpi-of-workshop-examples

openFrameworks overview

As said in the openFrameworks website:

openFrameworks is an open source C++ toolkit for creative coding.

True it is...

Based on C++

openFrameworks is written in C++ and basically it is C++ with all it's pros and cons.

Project directory structure

There are two main directories:

  • srcfor the source .h and .cpp files
  • binfor the compiled program files

File types

There are two basic file types:

  • .hor header files
  • .cppor C++ files

How it works

Just like Processing or Arduino it is all abouttwo functions for most of the time:

  • setup()
  • draw()

In Arduino there is a loop() functioninstead of draw()

Main functions

openFrameworks has three main functions:

  • setup()Does the initial setup when the program starts
  • update()Updates data, this is where to do the math
  • draw()Draw images, videos or anything else

Hands on

Let's start with the blankApp example to get our hands dirty and understand how it works by doing insted of talking.

Open the blankApp project directory Go to the src folder Open the main.cpp file

Get SFTP software

To test the project, we have to upload it to the Raspberry Pi. You need to have a SFTP file browser to do that.

If you don't have your favorite yet, download FileZilla.

Connecto to the Raspbery Pi

Open SFTP software and make a new connection to the Raspberry Pi. My settings are:

  • Address: 192.168.2.200
  • Username: pi
  • Password: raspberry

Upload files

Drop the blankApp project directory into the /Users/pi/openFrameworks/apps/myApps folder on the Raspberry Pi.

Compile project

Connect to the Raspberry Pi via SSH.

Navigate to the project directory:cd /Users/pi/openFrameworks/apps/myApps/blankApp Compile:make Run:make run

Makefile

There has to be a Makefile in the project folder to be able to compile the project. If it is not there, copy it from some of the default projects like emptyExample:

cp ../emptyExample/Makefile ./

Using addons

You need to have a addons.make file in your project directory. Simply enter the folder name of the addon you want to use in the file, separate multiple addons with a newline:

ofxMidi
ofxOsc

Sum-up

The process is basically the same for almost all projects:

Edit code Upload to the Raspberry Pi Compile and run

Hands on

Try out and examine code of the other examples from the workshop's Git repository.