Cinder++::Cinder Creative Coding Cookbook 1

I’m reviewing the Cinder Creative Coding Cookbook from packt publishing and written by Dawid Gorny and Rui Madeira. Its a kindly invitation from the packt publishing guys. The book do not explain what is Cinder or the C++ language. Thus the writers push you to the cinder world immediately. And you don`t have time to be afraid of cinder or c++.The book is structured in 12 chapters filled with many recipes, covering almost all the interactive and visually dynamic applications. Also the book target windows, mac and iOS platforms. During the following weeks I will upload (I hope*) my review for this book through a series of posts.

Cinder is an opensource C++ library for creative coding to develop graphics application, video, audio, image processing and computational geometry. You can program on cinder Visual C++ and OSX Xcode. Cinder provides a tool called TinderBox, which is bundled when you download the library. TinderBox contains different flavors templates to set Basic OpenGL applications, CocoaView OpenGL and screenSaver (if you are working with window). Also you can include other libraries using the assistance tool.

GETTING STARTED

When you launch a template in Cinder 5 methods are defined into the application class.
_ prepareSettings(). This method is called once at the beginning. Usually here you define for example the size of the window.
_ setup(). In this method you initialize all members and prepare the application for running.
_ update(). This method works as a loop during the runtime. Usually is used to animate and update the states of the application components.
_ draw(). This method also is called in a loop and is performed after the update(). here is where you place your drawings.
_ shutdown(). this is executed just before the application is shutdown, is useful to dispose resources.

ONE THING TO CONSIDER
If you are familiar with Java in Eclipse, or other .NET Language (C#), the first thing you will notice to run C++ it takes a while to see the outcome window. Nevertheless in this thread in Cinder’s forum you will have a good explanation of how to deal with this issue.

THE CODE:
This is my first code based in the first book example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
 
using namespace ci;
using namespace ci::app;
using namespace std;
 
class CinderProjectApp : public AppNative {
  public:
	void prepareSettings(Settings *settings);
	void setup();
	//void mouseDown( MouseEvent event );	
	//void update();
	void draw();
 
	int i;
};
 
void CinderProjectApp::prepareSettings(Settings *settings)
{
	settings->setWindowSize(200, 200);
	settings->setTitle("my first Cinder Application");
	settings->setFrameRate(10);
}
 
void CinderProjectApp::setup()
{
	i = 3;
}
 
//void CinderProjectApp::mouseDown( MouseEvent event ) {}
//void CinderProjectApp::update(){}
 
void CinderProjectApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 1.0f, 1.0f ) ); 
 
	gl::color(Color(0,0,0));
	gl::drawSolidCircle(Vec2f(100.0f, 100.0f), 40, i++);
 
	if(i == 50) i = 3;
}
CINDER_APP_NATIVE( CinderProjectApp, RendererGl )

OUTOCOME:
imp
 
*I don't like to say, I'm going to do this and that, because talk is easy,

Leave a Reply