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:
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
, andofFbo
—contain anofTexture
object instance that can be accessed by thegetTextureReference()
method. For example,video.getTextureReference()
gets theofTexture
object for a current frame of video.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 otherof...Primitive
classes have themapTexCoords
method, which sets texture coordinates; we will use it.The third step is activating texturing...