Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Texturing the sphere


Texturing is the technique to wrap a 2D image on a surface. In this case, the surface is called textured surface, and the image using for texturing is called texture.

Texturing involves the following three steps:

  1. The first step is preparing the texture image as an ofTexture object. We explored this class in the previous chapter. All the considered image and video classes—ofImage, ofVideoPlayer, ofVideoGrabber, and ofFbo—contain an ofTexture object instance that can be accessed by the getTextureReference() method. For example, video.getTextureReference() gets the ofTexture object for a current frame of video.

  2. Setting texture coordinates at each vertex of the surface is the second step. Texture coordinates at the given vertex indicate the point in the texture that should be wrapped at this vertex. Fortunately, ofSpherePrimitive and other of...Primitive classes have the mapTexCoords method, which sets texture coordinates; we will use it.

  3. The third step is activating texturing...