Getting started with Rajawali VR library

First step to getting started with Rajawali VR library is to extend your main Activity to VrActivity. VrActivity internally extends the google’s CardboardActivity providing a surface to render the 3D scene.

There might be a warning if onCreate access is protected, if so change it public

Setting up a sample scene with Rajawali

First, we need to extend the Rajawali Renderer class. Let’s create a new class where our MainActivity is:

Name the class say Renderer and select the superclass as VrRenderer

Implement methods and create a constructor matching super.

initScene is where you initialize the scene. Lets render a simple cube with a blue colored material:

Setting up the Activity

Now we need to set this renderer to our activity. Just create a new Renderer object and call the setRenderer method

You may also lock the orientation to landscape for the activity in the AndroidManifest.xml

The output will look like this:

Setting up the Manifest

To ensure the app can be launched from the cardboard app and the traditional launcher, add the following intent filter for the acitvity in the AndroidManifest.xml:

Your final manifest entry should look something like this:


Comments are closed.

Send Lesson #1
Join 1000s of VR Developers

Build your Career in VR with this 6 part FREE course

Send Lesson #1
Add Me To VIP
Join 1000s of VR Developers

We've build a simple curriculum to help you get started in VR

Send Lesson #1
We've launched a WebVR Course with 25+ projects with source code! Check it out.
Get The Course