Now with new hope some will be proud
This is no hoax, no one pushed out
Receive a reprieve and be a pioneer
Break new ground of a new frontier
New ideas will surely get by
No deed, or dividend. Some may ask "Why?"
You'll find the solution, the answers in the sky
-Dave Mustaine
A hundred times every day I remind myself that my
inner and outer life are based on the labors of
other men, living and dead, and that I must exert
myself in order to give in the same measure as I
have received and am still receiving...
-Albert Einstein
The worthwhile problems are the ones you can really solve or help solve,
the ones you can really contribute something to. ...
No problem is too small or too trivial if we can really do something about it.
-Richard Feynman
I have only two rules which I regard as principles of conduct.
The first is: Have no rules.
The second is: Be independent of the opinion of others.
-Albert Einstein
In everything, do to others what you would want them to do to you.
What we are is the sum of 1000 lives
What we know is almost nothing at all
But we are what we are until the day we die
Together we will find the strength to go on
-Rise against (intentionally missquoted and
taken out of context)
We need to be the change we wish to see in the world.
-Mahatma Gandhi
Seven social sins:
politics without principles,
wealth without work,
pleasure without conscience,
knowledge without character,
commerce without morality,
science without humanity,
and worship without sacrifice.
-Mahatma Gandhi
If I have seen further it is only by standing on the shoulders of giants.
-Isaac Newton
It is not enough to have a good mind.
The main thing is to use it well.
A loud "Fuck yeah!"
-From my heart (with James Hetfield's voice)
Contact me at:
Virtual reality - Lesson 1
In this first lesson you will learn how to setup your project in order to use the virtual reality library, this is something you will have to do for each new application you create. And while the final executable in this lesson will present nothing but a black window, it lays the ground for all future lessons, which makes reading it well worth it.

It is assumed that you are familiar with openGL, especially openGL for android. If you are new to openGL or openGL for android, I recommend that you first take a look at Nehe Android Ports at INsanityDesign.

It is throughout these lessons also assumed that development takes place in an Eclipse development environment. This is however not essential to much more than the content of this lesson, and most of the lessons that follows should be possible to follow without any modifications. If you develop in a differenet environment than Eclipse, this first lesson might however be a little more tricky, and you have to work out some of the steps by yourself. With just a little knowledge of your development environment, you should however have no problem of taking the information in this lesson and apply it in your own environment.

For the complete application produced in this lesson, click here. (Not very interesting, just a black screen. See lesson 2 for the first screen output, and 3 and forward for real virtual reality.)

Creating a project and adding the virtualreality.jar file
Start by creating a new project (File -> New -> Project, choose Andriod Project and Click next). Call the project VRFirst, choose "Android 1.5" as build target, and enter the following values into the property fields:
Application name: VRFirst Pacakage name: com.dafer45.virtualreality Create Activity: VRFirst Min SDK: 3
Finally click Finish.

The project is now created, and the next thing to do is to add the virtual reality library to it. To do this, right click the VRFirst folder in the Package window and create a new folder (New -> Folder). Enter libs as folder name and click Finish. Then copy VirtualReality_v0d1.jar into the libs folder. Next right click the VRFirst folder and select properties. From the left menu, choose "Java Build Path", click the "Libraries" tab, and then "Add JARs". Open "VRFirst/libs" and select the VirtualReality_v0d1.jar file and click OK twice.

Creating the layout file
Now open "/res/layout/main.xml" and replace the content with the following:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.dafer45.virtualreality.VirtualRealityView android:id="@+id/virtualRealityView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:keepScreenOn="true" /> </LinearLayout>
This defines a layout that consists of a single virtualRealityView which fills the whole screen and has the id "virtualRealityView". The last line android:keepScreenOn="true" ensures that the screen will not shut of after a few seconds of usage, which would be quite anoying here.

The manifest file
We are expected to turn the phone around alot when using it together with a virtual reality view. It does therefore not make sense to have the phone jumping between landscape and portrait mode. In addition, by default the android application is destroyed and recreated each time it passes between landscape and portrait mode. A behaviour we not want in this case. To solve this we add the following two line to the Activity-tag in the AndroidManifest.xml file:
android:screenOrientation="landscape" android:configChanges="orientation"
To do this, open AndroidManifest.xml and click the AndroidManifest.xml tab below the window and make sure that the content is the following
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="" package="com.dafer45.virtualreality" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".VRFirst" android:label="@string/app_name" android:screenOrientation="landscape" android:configChanges="orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="3" /> </manifest>

The Activity
Finally open the file "src/com.dafer45.virtualreality/" and make sure the content is the following
package com.dafer45.virtualreality; import; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class VRFirst extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window win = getWindow(); win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); } }
The line
is what sets our virtual reality layout to actually be displayed by the activity, and the three lines
Window win = getWindow(); win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE);
that preceeds it makes the title and statusbar disappear.

That's it
These steps completes our setup of the project. This is the most boring part, but is something that has to be done for each new project, and you will soon find yourself doing it very quickly. Once it's done we are ready to continue with the actual development, which will be a lot of fun!

Continue with lesson 2