You are previewing openFrameworks Essentials.
O'Reilly logo
openFrameworks Essentials

Book Description

Create stunning, interactive openFrameworks-based applications with this fast-paced guide

In Detail

openFrameworks is a cross-platform programming toolkit and library to perform creative coding in C++. It contains all you need to efficiently implement real-time tasks, such as generating 2D and 3D graphics, processing video and sound, and using networking.

openFrameworks Essentials is a guide that can be used for learning and using openFrameworks to develop creative and artistic real-time applications. It 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, reaction on sound, the OSC networking protocol, and the Arduino.

This book will empower you with the practical skills required to build creative apps and projects using openFrameworks.

What You Will Learn

  • Install openFrameworks and create a new project

  • Generate 2D and 3D graphics

  • Mix images and videos and process them with shaders

  • Add GUI controls and adjust them from external devices and apps using the OSC protocol

  • Control parameters with a timer, Perlin noise, and sound and text files

  • Use the Arduino to control your application

  • Build a video synthesizer project

  • Run your project on iOS, Android, and Raspberry Pi devices

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

    Table of Contents

    1. openFrameworks Essentials
      1. Table of Contents
      2. openFrameworks Essentials
      3. Credits
      4. Foreword
        1. The pro goes ashore
        2. The era of self-education
      5. About the Authors
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      9. 1. Getting Started with openFrameworks
        1. What is openFrameworks?
        2. Installing openFrameworks
          1. The openFrameworks folder structure
        3. Running your first example
        4. The video synthesizer application
          1. Three reasons to create your own video synthesizer with openFrameworks
        5. Summary
      10. 2. Creating Your First openFrameworks Project
        1. Creating and running a new project
          1. Creating a project
          2. Running a project
        2. Discovering the project's code structure
        3. Setting up the screen
        4. Centering the coordinate system
        5. A simple drawing
          1. Setting drawing color
          2. Drawing primitives
        6. Geometric patterns
          1. The stripe pattern
            1. A stripe pattern made from parallel lines
              1. Inserting the function declaration
              2. Inserting the function definition
              3. Inserting the function calling
            2. A stripe pattern made from rotating lines
            3. A stripe pattern made from rotating triangles
        7. Summary
      11. 3. Adding a GUI and Handling Keyboard Events
        1. Creating a GUI using the ofxGui addon
        2. Implementing a simple GUI panel with sliders
          1. Using the sliders' values
        3. Implementing the autosave feature
        4. Creating groups of controls
          1. Using the sliders' values
        5. Implementing a checkbox, a color selector, and a 2D slider
          1. Using the controls' values
          2. Experimenting with the project
        6. Handling keyboard events
          1. Hiding the GUI
          2. Saving a screenshot
          3. Saving a preset using the system save dialog
          4. Loading a preset using the system load dialog
        7. Implementing the matrix pattern generator
          1. Using the sliders' values
          2. Experimenting with the matrix pattern generator
        8. Summary
      12. 4. Working with Raster Graphics – Images, Videos, and Shaders
        1. Raster images in openFrameworks
        2. Drawing an image file
        3. Playing a video file
        4. Grabbing a live video from a camera
        5. Mixing layers using additive blending
          1. Creating the mixer's GUI
          2. Implementing the mixer's functionality
        6. Creating the video effect with a shader
          1. Redirecting drawing to the offscreen buffer
          2. Drawing the offscreen buffer contents and enabling smoothing
          3. Implementing the kaleidoscope effect
            1. Creating the fragment shader
              1. How it works
            2. Creating the vertex shader
            3. Using created shaders in the project
        7. Summary
      13. 5. Creating 3D Graphics
        1. Introduction to 3D graphics with openFrameworks
          1. openFrameworks classes for surface representation
        2. Drawing a wireframe sphere
        3. Creating a camera
          1. Controlling the camera with a mouse
            1. Disabling mouse control for the camera when the GUI is visible
          2. Camera automation
        4. Drawing a solid sphere
          1. The things needed for shading the surface
          2. Drawing a solid sphere with shading
        5. Texturing the sphere
          1. Preparing a texture
          2. Setting texture coordinates
          3. Activating texturing
        6. Mixing 2D and 3D with the GUI
        7. Deforming a sphere
          1. Deforming by formulas
          2. Extruding the sphere
        8. Summary
      14. 6. Animating Parameters
        1. Using time values for a parameter's automation
          1. Implementing a simple LFO
          2. Implementing a pseudorandom LFO with Perlin noise
        2. Using the level of sound for a parameter's automation
          1. Playing and analyzing an audio file
            1. Getting the level of a sound signal
        3. Capturing sound from a sound card's input and measuring its level
        4. Reading data from a text file
        5. Controlling automation
        6. Summary
      15. 7. Distributed and Physical Computing with Networking and Arduino
        1. Distributed computing with networking
        2. Networking in openFrameworks
          1. The ofxNetwork addon
          2. The ofxOsc addon
        3. Implementing the OSC messages receiver
        4. Creating an OSC sender with openFrameworks
          1. Sending OSC messages between two separate computers
            1. Connection troubleshooting
        5. Creating OSC senders with TouchOSC, Python, and Max/MSP
          1. Creating an OSC sender for a mobile device using the TouchOSC app
          2. Creating an OSC sender with Python
          3. Creating an OSC sender with Max/MSP
        6. Physical computing with Arduino
        7. Programming an Arduino board
          1. Receiving data from Arduino in the openFrameworks project
            1. Connection troubleshooting
            2. Connecting more devices
        8. Summary
      16. 8. Deploying the Project on iOS, Android, and Raspberry Pi
        1. Running the project on an iOS device
          1. Implementing video synthesizer for iOS
          2. Building a project for iPad
        2. Deploying the project on an iOS device
          1. Using accelerometer
        3. Running the project on an Android device
          1. Installing software for Android development
          2. Implementing video synthesizer for Android
            1. Creating an empty project
            2. Implementing the video synthesizer
          3. Increasing the size of the GUI panel
            1. Troubleshooting
          4. Implementing reaction on stopping and double-tapping
          5. Using the accelerometer on an Android device
          6. Renaming the project
        4. Running the project on Raspberry Pi
          1. Required equipment
          2. Setting up the device
          3. Installing openFrameworks
          4. Running the first example
          5. Implementing a video synthesizer for Raspberry Pi
        5. Summary
      17. 9. Further Resources
        1. Enhancing the video synthesizer project
          1. Speeding up the rendering
          2. Drawing curves and text
          3. Using fragment shaders for image generation
          4. Using vertex shaders for an object deformation
          5. Using the Firmata protocol for Arduino connection
          6. Multidisplay setup and sharing images between separate programs
        2. Getting more information on openFrameworks
          1. openFrameworks books
        3. Debugging and speeding up your code
          1. Debugging
          2. Speeding up the code
        4. Summary
      18. A. Video Synthesizer Reference
        1. The desktop version
          1. The openFrameworks project and source files
            1. Data files
          2. Control keys
          3. The GUI controls
            1. Basic sliders
            2. Global group
            3. Primitive group
            4. Mixer group
        2. iOS and Android versions
          1. The openFrameworks project and source files
          2. Data files
          3. The GUI
          4. Touches
          5. Accelerometer
        3. Raspberry Pi version
        4. Summary
      19. B. openFrameworks Quick Reference
        1. Application
        2. 2D drawing
        3. The GUI
        4. Multimedia and other classes
        5. Mathematical, timer, and conversion functions
        6. Summary
      20. Index