Cinder - Begin Creative Coding

By Krisjanis Rijnieks
  • Instant online access to over 8,000+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Learn Cinder Basics – Now!

About this book

Cinder is one of the most powerful professional grade C++ creative coding frameworks out there. It is open-source and peer-reviewed, meaning that there are experienced professionals behind its developmentand that every development step is taken seriously. Its philosophy is based on the capabilities of the operating system it is used for - Cinder will take the best from every OS and hardware you choose to work on.

Cinder - Begin Creative Coding will let you take your previous creative coding experience to a higher and also more demanding level. It will show you the Cinder way of using the most used creative coding functions for drawing, animation, interaction and allow you to do much more in terms of performance and cross-application-compatibility.

Starting by downloading Cinder and setting up the development environment, we will work through some of the most widely used topics in creative coding by creating and discussing simple sample applications.

Throughout this book we will deal with relatively simple topics like basic drawing, basic animation, basic 3D, interaction, loading files, playing back video files, applying built in and custom effects. Then going through to more advanced topics like how to use Cinder for a generative projection mapping project by using Syphon technology and how to connect Open Sound Control enabled applications for receiving and sending data and commands.

Cinder - Begin Creative Coding will bring your craziest ideas closer to the core of your computer by using the pure power of C++.

Publication date:
February 2013
Publisher
Packt
Pages
146
ISBN
9781849519564

 

Chapter 1. Learn Cinder Basics – Now!

In this chapter we will learn:

  • What is creative coding

  • What is Cinder

  • How to set it up on Mac OS X and Windows

  • How to test if the setup actually works

 

What is creative coding


This is a really short introduction about what creative coding is, and I'm sure that it is possible to find out much more about this topic on the Internet. Nevertheless, I will try to explain how it looks from my perspective.

Creative coding is a relatively new term for a field that combines coding and design. The central part of this term might be the "coding" one—to become a creative coder, you need to know how to write code and some other things about programming in general. Another part—the "creative" one—contains design and all the other things that can be combined with coding.

Being skilled in coding and design at the same time lets you explain your ideas as working prototypes for interface designs, art installations, phone applications, and other fields. It can save time and effort that you would give in explaining your ideas to someone else so that he/she could help you. The creative coding approach may not work so well in large projects, unless there are more than one creative codes involved.

A lot of new tools that make programming more accessible have emerged during the last few years. All of them are easy to use, but usually the less complicated a tool is, the less powerful it is, and vice versa.

Cinder is one of the most powerful tools in the world of creative coding. In this chapter, we will learn what Cinder is and how to set it up on the two most popular operating systems—Mac OS X and Windows. If you have access to both and you want to do it as fast as possible, choose Mac OS X. It won't take much longer on Windows, if you have a good Internet connection.

 

A few words about Cinder


So we are up to some Cinder coding! Cinder is one of the most professional and powerful creative coding frameworks that you can get for free on the Internet. It can help you if you are creating some really complicated interactive real-time audio-visual piece, because it uses one of the most popular and powerful low-level programming languages out there—C++—and relies on minimum third-party code libraries. The creators of Cinder also try to use all the newest C++ language features, even those that are not standardized yet (but soon will be) by using the so called Boost libraries.

This book is not intended as an A-to-Z guide about Cinder nor the C++ programming language, nor areas of mathematics involved. This is a short introduction for us who have been working with similar frameworks or tools and know some programming already. As Cinder relies on C++, the more we know about it the better. Knowledge of ActionScript, Java, or even JavaScript will help you understand what is going on here.

 

Downloading Cinder


Ok, less talk, do more! Point your browser to the Cinder website (http://libcinder.org).

Click on the Download link in the main menu and choose one of the following two versions depending on your operating system of choice:

  • Cinder for Mac OS X (Mac OS X)

  • Cinder for Visual C++ 2010 (Windows)

Note

We will be using the packed Cinder Version 0.8.4 throughout this book, but some differences between it and the newest Cinder Version 0.8.5 will be pointed out.

Now we are going to split the Cinder setup in two groups: Mac OS X and Windows. This is because of the configuration process, which is a bit different for each platform. You will get up and running faster if you use Mac OS X, but it is not blamable in case you appear to use Windows—just get yourself a good Internet connection and you are good to go!

 

Setting up Cinder on Mac OS X


Setting up Cinder on Mac OS X is relatively easy if you have done some coding before—that means, if you have Xcode installed. If not, you have to download and install it. To do that get yourself an Apple Developer Account from https://developer.apple.com/programs/register/.

Once you have your Apple Developer ID and password, go to the Xcode download section at https://developer.apple.com/xcode/ or open up the App Store application and search for the Xcode application there.

The process of installing Xcode is not a topic that we will be covering in this book, but it should be quite self-explanatory as Apple has a long history of making their applications as user friendly as possible. If you encounter problems with installing Xcode, try Google or go to the official Apple Developer Xcode FAQ located at https://developer.apple.com/support/xcode/.

So now you have Xcode installed on your computer! Let's move on and unarchive the downloaded Cinder package at a safe location, for example, /Users/Your_User-name/cinder. In my case, the path is /Users/kr15h/cinder.

Next, we are going to test if our newly created setup is working by opening one of the sample applications. We will try out the QuickTime sample application. To do that open the file quickTimeSample.xcodeproj (QuickTimeBasic.xcodeproj in Cinder 0.8.5) in the cinder/samples/QuickTime/xcode/ directory (cinder/samples/QuickTimeBasic/xcode/ in Cinder 0.8.5). In Xcode, select Build | Build and Run (Product | Run on Xcode 4+). You can achieve the same effect by pressing Cmd + R or by clicking on the Build and Run (simply Run in Xcode 4+) button in the toolbar (you can recognize it by a round green play button that is placed over a grayscale hammer or a round gray play button in Xcode 4+).

An Open File dialog should pop up. Go and select a movie file from your hard drive!

If you see the movie playing back in a window, success! You are ready to move on to the next chapter. If not, try to follow the steps mentioned in this section more carefully—maybe you did not notice something.

 

Setting up Cinder on Windows


Setting up Cinder on Windows might take a bit longer than on Mac OS X. That does not mean that it will work slower though. The thing that is good about Windows PCs is that you can usually be more elastic with your hardware configuration. So, if you have a strong will to create some wicked generative stuff with the right kind of hardware you choose, go for Windows and equip yourself with some QuadCore CPU, SSD hard drive, and appropriate GPU. It won' t hurt.

The main reason why configuring Cinder in Windows takes more time is that you'll have to download more stuff. Except the Cinder package, you also have to download and install the following.

Microsoft Visual C++ Express 2010

The reason of choosing this IDE is that all the official Cinder sample application projects are created for this one. Here we will use Microsoft Visual C++ as it is the default Windows IDE chosen by Cinder creators.

To download Microsoft Visual C++, point your browser at http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express.

Click on Visual C++ 2010 Express tab, choose the language to be downloaded, and click on Install. A download should start and when it is finished, open the *.exe file.

We will not cover the whole installation process, as it is not the scope of this book. Just choose the default options for everything and it will be fine. Let's move on to the next component we still need.

Windows Platform SDK

We need this software development kit (SDK) in order to communicate our programs with the Windows system. The Cinder framework will do it for us, so we won't see anything Windows specific—just multiplatform Cinder specific. Don't be afraid and download the Windows Platform SDK from http://bit.ly/IL35OV.

When the download is complete, do run it! Choose default options everywhere again and everything should be ok.

DirectX SDK

We need this because Cinder audio core relies on it. So let's get it from http://bit.ly/OSe24s.

Install with the default settings and you are good to continue.

QuickTime SDK

You do not need to download QuickTime SDK, if you are using Cinder 0.8.5.

You will have to get an Apple Developer Account to download it. Get it from https://developer.apple.com/programs/register/.

Then go to https://developer.apple.com/quicktime/.

Be careful while installing it. Cinder expects that QuickTime SDK resides in the same directory level (and with the directory name QuickTimeSDK-7.3) as Cinder itself. So, if you keep your Cinder in C:\cinder, the QuickTime SDK should reside at C:\QuickTimeSDK-7.3—change this while installing the SDK.

When you come to a point in the installation where you can choose the destination folder, click on the Change button.

Now change the Destination Folder path to C:\QuickTimeSDK-7.3.

If you are familiar with the re-linking libraries, do not bother yourself with this warning.

Launching the sample application

Before launching your first sample application, make sure that you have QuickTime Player installed on your system. If not, go to http://www.apple.com/quicktime/download/, download, and install it.

Go to the Cinder samples directory, for example, C:/cinder/samples/ and find a folder with the name QuickTime. Open C:/cinder/samples/QuickTime/vc10/quickTimeSample.sln.

Tip

Downloading the color images of this book

We also provide you 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:

http://www.packtpub.com/sites/default/files/downloads/9564OS_ColoredImages.pdf

Welcome to Microsoft Visual C++ 2010! Press F5 to build a project and run it. You should be provided with a prompt to choose a file—select a QuickTime compatible movie file from your hard drive and see what happens. You should see the movie playing back, and a semi-transparent rectangle with different stats about the movie file over it.

If you don't see the movie, check if you have QuickTime Player installed. First time I tried this sample application, I didn't succeed. And I spent hours trying to understand, what's wrong? Nothing! You just don' t have QuickTime Player. Get it from http://www.apple.com/quicktime/download/.

 

Summary


To sum up, these are the most simplest and fastest ways you can get Cinder up and running. There are other possible ways too, but they are out of the scope of this book. But if you search for the latest version of Cinder, check the CINDER + GIT section on the Cinder official website (http://libcinder.org/docs/welcome/GitSetup.html).

In the next chapter, we will try to understand what is possible with Cinder by launching different samples in the Cinder samples package.

About the Author

  • Krisjanis Rijnieks

    Krisjanis Rijnieks is a new media professional with a background in painting and multimedia. He holds a BA in painting and parallel to his painting studies he has been doing a lot of things related to print, video, web, Flash, Flash coding, and coding in general. It is not possible to name all the different categories of work, but through all this a strong interest towards interactive digital media has been developed. Creative coding is a new field that brings the art and design fields much closer to coding. As Krisjanis has been doing projects on both sides, the combination of the two seemed natural. It is a way of using ones creative visual and logical skills together without worrying that an unsolvable conflict between the left and right side of the brain will occur. For the past two years Krisjanis has been involved in many projects that include creative coding with technologies like Flash ActionScript, openFrameworks, Cinder, iOS, Unity 3D, Kinect, Augmented Reality, Quartz Composer, VDMX and projection mapping with MadMapper. Experience gathered throughout these projects requires searching for new and more powerful tools and skills constantly. Cinder a tool that allows one to combine the hottest topics of today’s computer science (computer vision, gesture recognition, etc.) with the craziest ideas and make them work real-time without acceleration lags. Currently Krisjanis is studying in the New Media MA program at the Aalto University School of Art, Design and Architecture, also known as the Helsinki Media Lab in Finland. He is also doing freelance commercial projects and taking his first entrepreneurial steps by managing his company called Skematic. This is the very first book Krisjanis has written, and it was fun and rewarding in terms of knowledge and experience.

    Browse publications by this author
Book Title
Access this book, plus 8,000 other titles for FREE
Access now