O'Reilly logo

Cinder – Begin Creative Coding by Krisjanis Rijnieks

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

Drawing in 3D

Let's try to draw something by taking into account that there is a third dimension.

Create another project by using TinderBox and name it Basic3D. Open the project file (xcode/Basic3D.xcodeproj on Mac or vc10\Basic3D.sln on Windows). Open Basic3DApp.cpp in the editor and navigate to the draw() method implementation.

Just after the gl::clear() method add the following line to draw a cube:

gl::drawCube( Vec3f(0,0,0), Vec3f(100,100,100) );

The first parameter defines the position of the center of the cube, the second defines its size. Note that we use the Vec3f() variables to define position and size within three (x, y and z) dimensions.

Compile and run the project. This will draw a solid cube at the top-left corner of the screen. We are ...

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