Rendering text

As we have just mentioned, to render text, we can't just call a drawText method that will render some text in 3D inside our small 3D scene. Actually, we'd be using drawText, but just to render it on a background Bitmap that would be used as a texture for an additional plane we will be rendering.

In order to do so, we'd have to define the geometry of that plane:

private float planeCoords[] = { 
        -1.f, -1.f, -1.4f, 
        -1.f,  1.f, -1.4f, 
         1.f,  1.f, -1.4f, 
         1.f, -1.f, -1.4f, 
}; 
 
private short[] planeIndex = { 
        0, 1, 2, 
        0, 2, 3 
}; 
 
private float texCoords[] = { 
        1.f, 1.f, 
        1.f, 0.f, 
        0.f, 0.f, 
        0.f, 1.f 
}; 

As the cube front face is at z-coordinate -1.f, this plane will be at -1.4f, so 0.4f in front of it, otherwise it might get occluded by the ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.