OpenGL ES does not provide built-in UI components, such as buttons, radio box, checkbox, and so on. In general, these components are called 2D widgets and are laid out in the HUD in the screen coordinate system, where the z component is either zero or not at all used. This recipe will guide us to design and lay out 2D widgets on the screen coordinate system using OpenGL ES.
This recipe contains two recipes:
The first recipe allows you to create the geometry of a simple button. Geometrical coordinates are specified in the local screen coordinate system, which is useful in designing the layout.
The second recipe is implemented in the There's more... section of this recipe, where we used the ray-picking technique, making the button clickable. Selecting the button will change its color.
The next image shows the output of the first recipe. It contains six buttons of 32 x 32 dimensions. Each button is scaled by a factor of two, resulting in the final dimension...