Skip to main content
February 23, 2016

Request for a simple 0.8 SDK graphics tutorial

Hi :D

I've seen the OculusRoomTiny demo and this simplified version : https://github.com/mattnewport/OculusRoomReallyTiny

which are great but still a bit beyond me with all the directx stuff. I understand the initialization, getting headtracking data but not all the graphics stuff.

Would anyone be willing to make a tutorial that demonstrates the absolute minimum needed to output something visual to the rift i.e. a triangle or even just a window with a background colour and/or some text.

Doesn't need to do anything ie no rooms chairs tables or flying balls no being able to move around etc like in the examples above.

Just a very simple graphical output to the rift using directx.

It would be greatly appreciated if someone would kindly do this?

    16 replies

    Up and Coming
    February 25, 2016
    https://github.com/cheery/lever/blob/ma ... in.lc#L268
    https://github.com/cheery/lever/blob/master/lib/vr.lc

    This is not an example, rather it's my actual use of the Oculus SDK.
    Up and Coming
    February 25, 2016
    "Zunfix" wrote:
    galopin very useful, thanks :D

    If it's only 30 extra lines of code then maybe you could put an example on github and provide a link :mrgreen: ?

    Once completed i'll do this for others to reference, for now here's a pic of me in action http://i.imgur.com/33h3pN0.jpg


    I do not work for free, show the money. You are incredible, do you want me to lace your shoes too ?

    As other saide tinyroom is really tiny to start with, and the oculus rift how to page is all you need (google any api i gave you to find the tutorial). i did not even looked at the samples to interface the sdk, only that page !
    February 25, 2016
    ^ did you notice the big green smiley face that followed my request, it was tongue in cheek... although i could pay you in IOU's for £1 million if you'll accept that?

    I do work for free.... plus nobody would pay me anyway :mrgreen:

    I found the oculus SDK documentation a bit vague but it should be clearer once i understand dx a bit more.
    March 1, 2016
    i got the code down in main.cpp to 226 lines without getting rid of error checking or comments etc, it does nothing but render a blank frame into a window and sets the window colour.

    i understand more of the tinyroom demo, it's impressive what it does considering how functional it is (the application) with so little code.

    ^^ thanks for the help ^^
    Inspiring
    March 4, 2016
    I have a couple of basic samples posted on GitHub, they mostly abstract the underlying graphics API, so it should work for you: https://github.com/kondrak/oculusvr_samples

    It's OpenGL though, so not sure how much that will help you.
    March 21, 2016
    I had used the Mr. Kondrak examples, extracted from them only the really necessary single classs and combined it with the most simple Glut code examples (Kondrak use OpenGl 4.0 - I modified the code to old-fashioned OpenGl 1.1).
    The code simply show one rotating triangle. The OculusVR class from Kondrak examples should be used as black box.
    Finally the super simple code can look like:

    #include <stdlib.h>
    #include <stdio.h>
    // this include OpenGL and glew stuff ...
    #include "OVR/OculusVR.hpp"
    #include <GL/glut.h>

    OculusVR g_oculusVR;
    static GLfloat angle=0;

    void display(void)
    {
    glDrawBuffer(GL_BACK);
    glClearColor(0.0, 0.0, 0.0, 0.0); /* black */
    glClear(GL_COLOR_BUFFER_BIT);

    glPushMatrix();
    glRotatef(angle,0,0,1);
    glBegin(GL_TRIANGLES);
    glColor3f(1,0,0); // red
    glVertex3f(-0.5,-0.5,0);
    glColor3f(0,1,0); // green
    glVertex3f(0.5,-0.5,0);
    glColor3f(0,0,1); // blue
    glVertex3f(0.0,0.5,0);
    glEnd();
    glPopMatrix();

    }

    void displayOVR(void)
    {

    g_oculusVR.OnRenderStart();

    for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
    {
    g_oculusVR.OnEyeRender(eyeIndex);

    display();

    g_oculusVR.OnEyeRenderFinish(eyeIndex);
    }

    g_oculusVR.SubmitFrame();
    g_oculusVR.BlitMirror();

    // simple animation
    angle=angle+1;
    if (angle>360) angle = 0;

    glutSwapBuffers();

    }

    int IntializeOVR()
    {
    // basic Rift intialization
    if (!g_oculusVR.InitVR())
    {
    return 0;
    }

    // activation of all GLEW supported OpenGl extensions
    if (glewInit() != GLEW_OK)
    {
    g_oculusVR.DestroyVR();
    return 0;
    }

    ovrSizei hmdResolution = g_oculusVR.GetResolution();
    ovrSizei windowSize = { hmdResolution.w / 2, hmdResolution.h / 2 };

    // creation of the Rift off screen rendering buffers
    if (!g_oculusVR.InitVRBuffers(windowSize.w, windowSize.h))
    {
    g_oculusVR.DestroyVR();
    return 0;
    }

    return 1;
    }

    int DeinitializeOVR()
    {
    // Rift deactivation
    g_oculusVR.DestroyVR();
    return 1;
    }

    int main(int argc, char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(960,540); // half OVR resolution size
    glutCreateWindow("Simple OpenGL/GLUT");

    IntializeOVR();

    glutDisplayFunc(displayOVR);
    glutIdleFunc(displayOVR);
    glutMainLoop();

    DeinitializeOVR();
    return 0; /* ANSI C requires main to return int. */
    }