O'Reilly logo

Building Android UIs with Custom Views by Raimon Ràfols Montané

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

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 ...

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