O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

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

RenderBox methods

Alright! We're getting closer. We're now ready to build a little scene in RenderBox using the code we created earlier. To start, the scene will simply consist of a colored cube and, of course, a camera.

At the beginning of this project, we created the skeleton RenderBox class, which implements CardboardView.StereoRenderer.

To this, we now add a Camera instance. At the top of the RenderBox class, declare mainCamera, which will get initialized in onSurfaceCreated:

    public static Camera mainCamera;

Note that Android Studio may find other Camera classes; ensure that it uses the one that we created in this package.

Shortly after your app starts and the MainActivity class is instantiated, the onSurfaceCreated callback is called. This is ...

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