Installing openFrameworks and running your first example
Now we will consider how to install openFrameworks in Windows, Mac OS X, and Linux, and execute one of the openFrameworks' examples.
Note
Historically (and currently) openFrameworks works best in Mac OS X. So when we use openFrameworks in interactive performances, we often do it in Mac OS X. Because performance is a short event (5 to 30 minutes), it is highly critical the software works as maximally fast and stable as it can.
For interactive installations, which are exhibited for a longer time (hours to months), and rare interruption in work is not so critical, we use any OS, depending on the available hardware.
The installation files and setup guides for all supported operating systems are located at http://www.openframeworks.cc/download/. Let's consider them in detail.
Installing on Windows
Within Windows 7 and 8 there are two choices of programming environments: Microsoft Visual Studio and Code::Blocks. Microsoft Visual Studio is one of the most popular environments in the world. It is very mature and stable. Many libraries (included and not included in openFrameworks) are adopted for Visual Studio. So if you are a novice in C++ programming, but you know that you need to link additional libraries in your project, Visual Studio is the best option for you.
Code::Blocks is a more lightweight environment and some developers prefer to use it. If you are a novice and just want to play with openFrameworks in simple projects, you should probably to do it with Code::Blocks.
Microsoft Visual Studio
The current version of Microsoft Visual Studio is 2012. In general Microsoft Visual Studio 2012 is a commercial software. But it has a lightweight free version, Microsoft Visual Studio Express, which is full enough for developing projects with openFrameworks.
The installation steps are as follows:
Install Microsoft Visual Studio Express 2012 for Windows Desktop. Navigate to http://microsoft.com, enter
Visual Studio Express 2012 for Windows Desktop download
in the search line, and press Enter to start searching. Click the Download button. When downloading page opens, press the Install now button. Then you will go through the process of installation. When installation is finished, run Visual Studio and register it (registration is free).Download the openFrameworks' archive. Go to http://www.openframeworks.cc/download/ and download the version for Visual Studio. The downloaded ZIP file should be named like
of_v0.8.0_vs_release.zip
. Unzip the downloaded file; it will be a folder containing openFrameworks. Move the folder to any location on your computer, for example,C:\openFrameworks
.Let's compile and run some example to verify openFrameworks is working correctly. Navigate to the
examples/3d/pointCloudExample
openFrameworks folder and openpointCloudExample.sln
in Visual Studio.Press F7 to compile the project.
Press F5 to run the project.
You will see an application window with a boy's face made from 3D points as shown in the following screenshot:
Press the left mouse button and move the mouse to rotate the face, or press the right mouse button and move the mouse to scale the face.
Note
To understand the code of the example you need to learn how to work with images and 3D graphics, see Chapter 4, Images and Textures, and Chapter 7, Drawing in 3D. For creating your own point cloud, for example, from your own face, you need to learn how to work with depth cameras, see Chapter 10, Using Depth Cameras. Also check out the description of the project's files in the File structure of a project section.
Also, note the second window associated with the running application. It is colored in black and possibly contains some text. This is a console window, where openFrameworks writes various information, warnings, and errors. When you have some problems, check the contents of this window.
Now press Esc for closing the application.
You have successfully run the openFrameworks example and now can develop your own projects.
Tip
If you try to run a project made with Visual Studio on some other computer, it will probably not start, and show an error message. The possible reason is that you need to install Visual Studio redistributables. To download it, go to http://microsoft.com, enter Visual C++ Redistributable for Visual Studio
in the search line, and press Enter to start searching. Click on the first search result and download the installation file.
Before installing the redistributables, try to run your project. Maybe it will work.
Code::Blocks (Windows)
Code::Blocks is an open source development environment for Windows. The current version is 12.11. The installation steps are as follows:
Install Code::Blocks. Go to http://www.codeblocks.org, click on the Downloads menu item, and click on Download the binary release. Then select the file to download, which includes mingw. For example,
codeblocks-12.11mingw-setup.exe
.Install additions for Code::Blocks, which are needed for openFrameworks working. Go to http://www.openframeworks.cc/setup/codeblocks/ and see instructions in the Add files to MinGW section.
Download the openFrameworks archive. Go to http://www.openframeworks.cc/download/ and download openFrameworks for Code::Blocks (Windows). The downloaded ZIP file should be named like
of_v0.8.0_win_cb_release
. Unzip the downloaded file; it will be a folder containing openFrameworks. Move the folder to any location on your computer, for example,C:\openFrameworks
.Let's compile and run an example to verify openFrameworks is working correctly. Navigate to the
examples/3d/pointCloudExample
openFrameworks folder and openpointCloudExample.workspace
in Code::Blocks.The first time you open Code::Blocks it will ask you which compiler you want to use. Be sure GNU GCC Compiler is selected and continue.
Press the Build button and then the Run button:
Follow the steps 6, 7, 8, and 9 from the Microsoft Visual Studio section.