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 where we can clear the screen, allocate buffers, and build shader programs. Let's add that now:
public void onSurfaceCreated(EGLConfig eglConfig) { RenderBox.reset(); GLES20.glClearColor(0.1f, 0.1f, 0.1f, 0.5f); mainCamera...