O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A single particle

In this section, we will create a project that will model and draw one particle. It will be represented by our custom C++ class, Particle.

The best C++ programming style suggests declaring and implementing each new class in separate .h and .cpp files (in our case, it should be Particles.h and Particles.cpp) because it improves readability and reusability of the code. But for simplicity, we will declare and implement all the classes of the example only in testApp.h and testApp.cpp files respectively.

Note

This is example 03-Particles/01-SingleParticle.

The example is based on the emptyExample project in openFrameworks. In the testApp.h file, after the #include "ofMain.h" line, add the following declaration of a Particle class:

class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required