Perevalov | Mastering openFrameworks: Creative Coding Demystified | E-Book | www.sack.de
E-Book

E-Book, Englisch, 364 Seiten

Perevalov 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.
1. Auflage 2025
ISBN: 978-1-84951-805-5
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)

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.

E-Book, Englisch, 364 Seiten

ISBN: 978-1-84951-805-5
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)



openFrameworks is a powerful programming toolkit and library designed to assist the creative process through simplicity and intuitiveness. It's a very handy software library written in C++ to reduce the software development process, helping you to kick-start creative coding. With the help of C++ and shaders support, openFrameworks allows for the processing of all kinds of media information with your custom-developed algorithms at the lowest possible level, with the fastest speed.

'Mastering openFrameworks: Creative Coding Demystified' will introduce you to a world of creative coding projects, including interactive installations, audio-visual, and sound art projects. You will learn how to make your own projects using openFrameworks. This book focuses on low-level data processing, which allows you to create really unique and cutting-edge installations and projects.

'Mastering openFrameworks: Creative Coding Demystified' provides a complete introduction to openFrameworks, including installation, core capabilities, and addons. Advanced topics like shaders, computer vision, and depth cameras are also covered.

We start off by discussing the basic topics such as image and video loading, rendering and processing, playing sound samples, and synthesizing new sounds. We then move on to cover 3D graphics, computer vision, and depth cameras. You will also learn a number of advanced topics such as video mapping, interactive floors and walls, video morphing, networking, and using geometry shaders.

You will learn everything you need to know in order to create your own projects; create projects of all levels, ranging from simple creative-code experiments, to big interactive systems consisting of a number of computers, depth cameras, and projectors.

Perevalov Mastering openFrameworks: Creative Coding Demystified jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


Code structure of a project


Source codes of an openFrameworks' project are placed in the project's folder and consist of at least three files: , , and .

Note


Remember the following convention: if some function or class name begins with , it means that it belongs to openFrameworks. Examples are , , and . (If some name begins with , it means that it is part of some openFrameworks addon, for example, .)

main.cpp


In C++ language specification each project must have a file with the defined function. This function is an entry point for an operating system to start the application. In openFrameworks, the function is contained in the file. The most important line of the function is the following:

ofSetupOpenGL( &window, 1024, 768, OF_WINDOW );

This function calling instructs openFrameworks that you need to create a window for visual output with the width and height pixels. The last parameter means that you need to create a window, which the user can move and resize on the desktop screen. If you specify the last parameters as , the project will run at full screen—such a mode is important for many projects.

For example, if you need to show your project on the full screen with dimensions x pixels, you can do it by replacing the call with the following line:

ofSetupOpenGL( &window, 1920, 1024, OF_FULLSCREEN );

Normally you need not change the file at all, because the settings of screen size can be done in the text, which we consider now.

Tip


Be careful! Inside the function most of the openFrameworks objects such as do not work properly, because paths and other variables are not set yet. So, indeed, in most cases you should keep untouched and do all you need in .

testApp.h


This file begins with . This is a compiler directive, which should be present at the beginning of all the files. The next line is . It includes openFrameworks' core classes and functions. After this, the code contains declaration of the class, which is inherited from the openFrameworks' class:

#pragma once #include "ofMain.h" class testApp : public ofBaseApp{ public: //openFrameworks' standard functions declarations void setup(); void update(); void draw(); //... //Declarations of custom objects for the project ofEasyCam cam; ofMesh mesh; ofImage img; };

The class contains a number of functions, , , (), and some others. These are the functions required for your project to work. They are defined in the class and called by openFrameworks. (The linking of the class to the openFrameworks engine is done within the function. Its last line creates an object of this class and links it to the window, controlled by openFrameworks.) We will describe the meaning of the functions in the next section.

In the end of the class definition you will see declarations of the , , and objects. These are custom objects defined just in this example. In your own projects, you should add declarations of your objects here too.

Note


For simplicity you can declare objects right in the file, but be careful, objects of some classes like , , and will not work properly and can cause the application to crash if defined as static variables not belonging to the class. The reason is that openFrameworks performs some actions before the class' object is created, and such classes rely on this. Note that in some examples of the book we sometimes use such declarations for simple types (, , , , and others).

Let's sum up: when creating your own project you should keep declarations of the , , functions, and others untouched, and also add your objects' and functions' declarations, which are needed for your project.

testApp.cpp


The file contains definitions of all functions, declared in . Let's explain the standard functions of the class.

The most important functions are , , and . is called first, and then and are called in an infinite cycle, until the user presses the key to close the project:

Note


Besides pressing , to finish the projects' execution, the user can just close the projects' window.

If you need the project to terminate itself, call the function with some integer value .

Let's consider these functions in detail.

setup()


The function is called by openFrameworks just once, at the start of the project. This is the best place for setting screen parameters such as refresh rate, load images and videos, and start processes like camera grabbing.

The typical functions for controlling screen parameters are the following:

  • : This parameter sets the frame rate of screen refresh equal to the value of type . Also, it controls the rate of calling and . The typical value is 60, which corresponds to the frame rate of most TVs and projectors. The default value is zero, which means that the frame rate is as large as possible (in some cases it is unwanted).
  • : This parameter enables or disables synchronization of screen refresh with the video card's physical refresh, with of type . Enabling this mode improves the quality of a fast-moving object's rendering, but slightly decreases the performance. By default the synchronization is enabled.
  • : This parameter enables or disables full screen mode, with of type .
  • : This parameter sets the size of the output window so that the drawing area will have size width and height pixels.

Note that you can call these functions from other functions of the class too.

update()


This function is called by openFrameworks right after the call. This is the place where all computations should be performed, like changing positions of objects, analyzing data from cameras, and network exchange.

Tip


Also, drawing into offscreen buffers (FBOs) can be done here.

draw()


This function is called by openFrameworks after . All drawing functions should be placed here. After , openFrameworks again calls , so we obtain a cycle of the and methods.

The typical drawing functions are as follows:

  • , where , , and are integer values from to , specifying red, green, and blue components of screen background
  • sets the drawing color
  • draws a line segment connecting points (, ) and (, )

Other functions


The file contains definitions of other functions, declared in . These are event-driven functions; openFrameworks calls them when some event occurs, like mouse moving or keyboard pressing. Some of the most important functions are the following:

  • The and functions are called by openFrameworks when some key is pressed or released. Here is an value, which can be compared with char values like , and with constants denoting special keys like...


Perevalov Denis :

Denis Perevalov is a lecturer and programmer from Ekaterinburg, Russia. He teaches creating interactive media projects at Ekaterinburg Academy of Contemporary Art, and teaches 3D graphics at Ural Federal University. Also he is scientist the Krasovsky Institute of Mathematics and Mechanics.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.