Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

openFrameworks Essentials is a guide that can be used to learn and use openFrameworks in order to develop creative and artistic real-time applications. The book contains an insight into how openFrameworks can be used to implement your creative ideas in powerful projects by working on the OS X, Windows, Linux, iOS, Android, and Raspberry Pi devices. Although openFrameworks is a very popular toolkit for creative coding, the number of books describing openFrameworks is not high.

This book is a fast-paced tutorial that begins with installing openFrameworks and then takes a step-by-step approach towards using openFrameworks to build a video synthesizer project. We will investigate and implement features such as 2D and 3D graphics, GUI, shaders, and reaction on sound, using the OSC networking protocol and Arduino.

The openFrameworks version considered is 0.8.4.

What this book covers

Chapter 1, Getting Started with openFrameworks, introduces openFrameworks by explaining its installation and running one of its examples. Additionally, it discusses the structure of the video synthesizer project, which will be developed in the course of the book.

Chapter 2, Creating Your First openFrameworks Project, guides you to create a new openFrameworks project and implement 2D graphics.

Chapter 3, Adding a GUI and Handling Keyboard Events, explains creating a graphical user interface consisting of controls such as sliders and checkboxes. Also, it covers implementing keyboard events, using system dialogs, and saving screenshots.

Chapter 4, Working with Raster Graphics – Images, Videos, and Shaders, explains drawing images and videos, capturing video from a camera, mixing videos using additive blending, and creating the kaleidoscope video effect using a fragment shader.

Chapter 5, Creating 3D Graphics, introduces the basics of 3D graphics with openFrameworks by drawing a sphere in 3D and then texturing and deforming it.

Chapter 6, Animating Parameters, discusses using various data sources, such as Perlin noise, sounds, and text files, to automatically control the parameters of the project.

Chapter 7, Distributed and Physical Computing with Networking and Arduino, explains how to control your project from other programs using the OSC networking protocol. It describes building such controlling programs using openFrameworks by itself as well as the Python and Max/MSP programming languages. Also, it covers receiving data from an Arduino device.

Chapter 8, Deploying the Project on iOS, Android, and Raspberry Pi, guides you to run the light version of the developed video synthesizer on mobile and Raspberry Pi devices.

Chapter 9, Further Resources, suggests the direction to further enhance the video synthesizer project, provides sources of additional information on openFrameworks, and discusses debugging and speeding up openFrameworks projects.

Appendix A, Video Synthesizer Reference, is a comprehensive documentation of the developed video synthesizer project. It contains a description of all GUI controls, control keys, and media files used by the project.

Appendix B, openFrameworks Quick Reference, is a useful reminder of the basic openFrameworks functions and classes used in the book.

What you need for this book

openFrameworks is a cross-platform toolkit, so you can develop openFrameworks projects using your operating system of choice—OS X, Windows, Linux Ubuntu, Debian or Fedora, or Raspbian OS. To build the projects, you will need to install the C++ IDE and openFrameworks itself. All the required software is free; detailed instructions on installing are explained in Chapter 1, Getting Started with openFrameworks.

To proceed with some sections, you will need additional software (Python and Max/MSP) or hardware (camera, microphone, iOS, Android, Raspberry Pi, and Arduino devices). If you currently don't have any devices, you can skip the corresponding section(s).

Who this book is for

The book is intended for those who want to use openFrameworks to build creative projects that run at maximum efficiency on desktops and mobiles. Perhaps you have some experience in creative coding but have never used C++ and openFrameworks, or perhaps you know a little C++ but are new to creative coding. In either case, this book will get you up and running quickly. A basic knowledge of programming languages, such as C++, Java, Python, or JavaScript, will be enough to proceed with the book.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The class for playing videos is ofVideoPlayer."

A block of code is set as follows:

ofSetWindowTitle( "Video synth" );
ofSetWindowShape( 1280, 720 );
ofSetFrameRate( 60 );
ofBackground( ofColor::white );

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

for (int i=-50; i<50; i++) {
  ofPushMatrix();
  ofTranslate( i*20, 0 );
  ofLine( 0, -100, 0, 100 );
  ofPopMatrix();
}

Any command-line input or output is written as follows:

cd openFrameworks/libs/openFrameworksCompiled/project

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the GENERATE PROJECT button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/6145OS_Graphics.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.