Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering openFrameworks: Creative Coding Demystified

You're reading from   Mastering openFrameworks: Creative Coding Demystified openFrameworks is the doorway to so many creative multimedia possibilities and this book will tell you everything you need to know to undertake your own projects. You'll find creative coding is simpler than you think.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781849518048
Length 364 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Denis Perevalov Denis Perevalov
Author Profile Icon Denis Perevalov
Denis Perevalov
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Mastering openFrameworks: Creative Coding Demystified
Credits
Foreword
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. openFrameworks Basics FREE CHAPTER 2. Drawing in 2D 3. Building a Simple Particle System 4. Images and Textures 5. Working with Videos 6. Working with Sounds 7. Drawing in 3D 8. Using Shaders 9. Computer Vision with OpenCV 10. Using Depth Cameras 11. Networking Working with Addons Perlin Noise Index

Addons basics


Though openFrameworks' core has powerful capabilities for processing and generating various kinds of multimedia data, it does not contain everything. For example, the core does not contain support for depth cameras, processing the images using the computer vision library OpenCV, or sending and receiving data via a network.

For using such capabilities in your project, you would link and use any of the C++ or C external libraries that are available on the Internet. But, each library is different so using them in your project is sometimes easy and sometimes not. Fortunately, openFrameworks has a friendly mechanism for plugging libraries to your project. Such a mechanism is called an addon.

Most often, an addon is a class that acts as a wrapper for a library. Also, the addon contains the library itself in a form that is ready to be linked to your project binaries. This relation is shown in the following image:

The term wrapper here means that it lets your project and a library communicate in some way. openFrameworks' addon mission is to simplify such a communication and do it in a standardized way (in "the openFrameworks's style"). Hence, you do not need to learn about a library interface and its usage but just learn how to use an addon, and that would be enough for most situations. So using addons accelerates project development a lot. Furthermore, when you need deeper capabilities of the library, not included in the addon, you can always access them by reaching the library objects and functions directly or through the addon's class members.

Remember, an addon is just an openFrameworks extension; it only links to a project, which is using it, but does not affect the other projects and openFrameworks itself.

Sometimes an addon is not a wrapper, but just a class that adds some new functionality without linking any new library to the project. See the following image:

Addons in openFrameworks

Every openFrameworks's addon class name begins with ofx. This is an acronym for openFrameworks extension. For example, ofxXmlSettings is a class for writing and reading settings in XML files.

Addons are located in the addons folder of openFrameworks. The examples of addons' usage are located in the examples/addons folder of openFrameworks.

There are two classes of addons. The first class of addons is called core addons and is distributed with openFrameworks. You have the addons of this class in the addons folder right after installing openFrameworks. They are stable and useful addons that are needed in many interactive projects.

The second class of addons is called non-core addons and are available for download at http://ofxaddons.com. There are both mature addons as well as the ones currently in development. Please test them carefully before using them in your installations or performances. Fortunately, all the addons have open code, and you can always check and modify them. Nevertheless, sometimes addons have binary .lib or .a files; it is very difficult to find and correct errors in such addons rapidly, so again, test addons before using them.

Installing a non-core addon

To install a non-core addon into openFrameworks, perform the following steps:

  1. Go to http://ofxaddons.com, find the desired addon and click on its name.

  2. The addon's page will be opened. The page contains addon's description and downloading button. Currently download button is named Download ZIP and is located in the right part of the page. Press it to download the addon's archive.

  3. Unpack it into the openFrameworks' addons folder.

  4. If the name of the unpacked folder containing an addon does not match the addon's name, for example, ofxOpenNI-master.zip, rename the folder to the addon's name, ofxOpenNI.

  5. If the addon's folder contains examples of its usage, it is a good idea to move the examples to the examples/addons folder.

The world of addons is rapidly evolving. New addons appear and are renamed regularly. The most useful non-core addons eventually become core addons. And some core addons migrate into openFrameworks core. (Then the ofx prefix in the class name turns into of). So, it would not make much sense to discuss all the existing addons because next year, the list could be totally outdated. Nevertheless, we will discuss the current core and some non-core addons in the List of selected addons section.

Tip

Adding new capabilities to your projects using addons is very easy and comfortable. But there are many libraries and algorithms that have not been implemented in addons yet. So if your project needs some functionality, and if there are no addons for this, don't be upset and solve the problem without addons. For example, if you need to control a new device from your project, then find its SDK, the library or example of its usage, and use it in your C++ project directly without addons.

Once you succeed in doing this, you can package your code as an addon and publish it for the openFrameworks' community by following the recommendations at http://www.ofxaddons.com/howto/.

Now we will talk about linking addons to your project.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image