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

Simple 3D drawing

For simple 3D drawing in openFrameworks, follow these steps:

  1. Add the ofEnableDepthTest() function call in the beginning of the testApp::draw() function to enable z-buffering. If you omit it, all the graphics objects will be rendered without respect to their z coordinate in correspondence with the graphical primitives' rendering order.
  2. Draw primitives as follows:
    • The ofLine( x1, y1, z1, x2, y2, z2 ) function draws a line segment between points (x1, y1, z1) and (x2, y2, z2). There is an overloaded version of the function, ofLine( p1, p2 ), where p1 and p2 have type ofPoint. Use the ofSetColor() and ofSetLineWidth() functions to adjust its rendering properties of color and line width.

      Note

      In Chapter 2, Drawing in 2D, we used the ofPoint ...

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