Introducing RenderBox – a graphics engine
In a virtual reality app, you are creating a three-dimensional space with a bunch of objects. The user's viewpoint, or camera, is also located in this space. With the help of the Cardboard SDK, the scene is rendered twice, once for the left and right eye, to create the side-by-side stereoscopic views. The second and equally important feature translates the sensor data into a head look direction, tracking the real-life user's head. The pixels are drawn on the screen, or rendered, using the OpenGL ES library, which talks to the hardware graphics processor (GPU) on your device.
We're going to organize the graphics rendering code into separate Java classes, which we'll be able to extract into a reusable graphics engine library. We'll call this library RenderBox.
As you'll see, the RenderBox
class implements the CardboardView.StereoRender
interface. But it's more than that. Virtual reality needs 3D graphics rendering, and to do all this in low-level OpenGL...