, , , , , , , , , , , , ,

Arkwood cried. I turned a page of my broadsheet newspaper.

‘I want another world!’ he wailed. Daphne – the plump spotty girl who works down the chippy – had dumped him again.

‘The dollar is up on the yen,’ I stated casually.

But, alas, I relented. ‘Okay, I will build you a virtual world so you can escape your pain.’

I started to read over the PC SDK documentation for the Oculus Rift virtual reality headset.

After creating an Oculus account and installing the Oculus Rift PC runtime on my Windows 10 PC, it was time to get my mitts on the Oculus SDK for Windows V1.7.0.

The PC SDK comes with some handy sample applications for Microsoft Visual Studio. Perfect, as I already have the free Microsoft Visual Studio 2015 Community installed.

The OculusRoomTiny (GL) sample application – which makes use of the OpenGL graphics library – is a sparse virtual world containing a table and chair and a floating cube. Let’s tinker with the C++ code and add our own object.

Open the Win32_GLAppUtil.h file and add the following code below the Model’s AddSolidColorBox function:

// add triangle
void AddTriangle()
	// triangle vertices
	Vector3f TriangleVertices[][2] =
		Vector3f(1.0f, 0.0f, -2.0f), Vector3f(0.0f, 0.0f),
		Vector3f(2.0f, 0.0f, -2.0f), Vector3f(1.0f, 0.0f),
		Vector3f(1.5f, 1.0f, -2.0f), Vector3f(0.5f, 1.0f)

	// triangle indices
	GLushort TriangleIndices[] =
		0, 1, 2,
		2, 1, 0

	// add indices
	int indexCount = sizeof(TriangleIndices) / sizeof(TriangleIndices[0]);
	for (int i = 0; i < indexCount; ++i)
		AddIndex(TriangleIndices[i] + GLushort(numVertices));

	// add vertices
	int vertexCount = sizeof(TriangleVertices) / sizeof(TriangleVertices[0]);
	for (int v = 0; v < vertexCount; v++)
		Vertex vertex;
		vertex.Pos = TriangleVertices[v][0];
		vertex.U = TriangleVertices[v][1].x;
		vertex.V = TriangleVertices[v][1].y;
		vertex.C = 0xff202050;


We are going to render a simple triangle into the virtual world.

First up we create the three vertices of our triangle, along with UV values for its texture. For example, the triangle’s top point has an x coordinate of 1.5, a y coordinate of 1.0 and a z coordinate of -2.0, and has texture UV values of 0.5 and 1.0.

Next we set the index values for drawing the vertices. Notice that we have six indices. Since the application has the OpenGL setting glEnable(GL_CULL_FACE) in place, we need to be sure to draw both sides of our triangle (otherwise or triangle will disappear when we walk around it!)

Finally, we add our indices and vertices to our model. Each vertex colour is set to 0xff202050.

Okay, so adding a triangle to the virtual world is not going to mend Arkwood’s broken heart. He might perk up – so to speak – if I were to render a scantily clad temptress. But a three-sided shape? It’s unlikely to get his juices flowing.

But it’s a start.

One more bit of code requires to be added, at the end of the Scene’s Init function:

// add model for triangle
m = new Model(Vector3f(0, 0, 0), grid_material[1]);

We create a new model with an x, y and z position of 0 and a brick texture. After adding our snazzy triangle to the model, the model is added to the scene.

Okay, so let’s run the application and feed Arkwood that sexy geometry.

Note: you will need to enable Oculus to run software from unknown sources, instructions on the Getting Started with the SDK page.

‘There is one small problem,’ I said to Arkwood, ‘I don’t actually have an Oculus Rift headset yet. Fingers crossed for next Tuesday, it will be in my paws.’

My chum sobbed.

‘Don’t worry though, I can still show you the treat that awaits!’

I opened the SDK Tools folder and ran the OculusDebugTool.exe file:


Simply change the Debug HMD Type to CV1 and we are ready to display the virtual world in a window on our PC.

Right-click the OculusRoomTiny (GL) application in Visual Studio and select Debug – Start new instance. A window will open, presenting a virtual world. Use the arrow keys on the keyboard to navigate around the virtual world containing a table and chair and a floating cube. And a triangle!


‘What do you think!’ I said eagerly to Arkwood, ‘isn’t she an equilateral beauty!’

My buddy looked at me long and hard. ‘I’m doomed,’ he replied coldly.