Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
anarkavre's avatar
anarkavre
Honored Guest
12 years ago

Oculus Rift SDL2 OpenGL Demo (Updated for Oculus SDK 0.4.0)

I updated the demo to work with the new SDK. Positional tracking is not applied to the camera, but it can easily be added. You can access the source code here. Here are two screenshots for those who are curious.

8 Replies

  • sth's avatar
    sth
    Honored Guest
    Very useful reference. Thanks for posting this!
  • Thanks for the code.
    I tried it on Win7, DK2, GeForce 560 and it runs in extended mode, but not in direct HMD mode :-(

    If I understand the SDk correctly, we have to call ovrHmd_AttachToWindow() in case the system is set to direct HMD mode, so added this after the ovrHmd_ConfigureRendering call:

    	bool riftIsUsingExtendedDesktop = (bool)(hmd->HmdCaps & ovrHmdCap_ExtendDesktop);
    if (!riftIsUsingExtendedDesktop) {
    ovrHmd_AttachToWindow(hmd, cfg.OGL.Window, nullptr, nullptr);
    }


    However, still no luck. Did you get an OpenGL example to run in direct HMD mode with a DK2?
  • Wouldn't the direct rendering mode take over the function now taken by SDL2, create a window with a opengl context with it's own method?
  • "ElectricMucus" wrote:
    Wouldn't the direct rendering mode take over the function now taken by SDL2, create a window with a opengl context with it's own method?


    ovrHmd_ConfigureRendering() is checking some OpenGL extensions, so it is assuming an existing context (but didn't build one).
  • allenc's avatar
    allenc
    Honored Guest
    Hi - as a newcomer to Oculus development, I really appreciate the idea of this demo... but I haven't been able to get it to compile. I've been struggling over several sessions to get the linker/compiler set correctly in VS2013 with no luck.

    [I have been doing software development for a little while but haven't needed to change the project configuration much (or I have inherited projects with the changes already made) and this is the first time I have used SDL (at least, since school).]

    I extracted the GLEW, SDL2, and LibOVR SDKs, added the include folders to the project's 'additional include directories', added the lib folders to the 'additional library directories', and added the lib files (libovrd.lib, winmm.lib, sdl2.lib, sdl2main.lib, glew32.lib) to the 'additional dependencies'.

    But I consistently get Error - xxx already defined in LIBCMTD.lib or MSVCRT.lib.

    Anybody else encountered this and know the solution?

    Thanks!
  • "allenc" wrote:
    But I consistently get Error - xxx already defined in LIBCMTD.lib or MSVCRT.lib.


    Things that usually cause that are redundant calls to the same library (already included in a sub-package, for example), multiple copies of the same library (also referenced multiple times, but not in the same physical locations), or namespace collisions.
  • Hey Im trying to port my SDL/OpenGL game engine to the latest SDK and came across this example, but unfortunately I cant get it to work either. Ive created a new project and downloaded the latest glew/stl and oculus sdk.

    If I include the line #define GLEW_STATIC and link with glew32s.lib I get lots of multiply defined symbols errors such as :

    Error 1 error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR120D.dll) \\battlestar\Documents\Projects\TestRift\TestRift\LIBCMT.lib(invarg.obj) TestRift

    Im using Multi-threaded Debug DLL (/MDd) runtime library, but Ive tried all possible settings for this flag in my project and no luck.

    I can get the project to compile if I remove that line and instead link against glew32.lib, however when it runs I get an assertion at line 170 of the file CAPI_GL_HSWDisplay.cpp. Its in the method LoadTextureTga. I guess this is where the sdk is loading the warning message. Crazy!!!! Ive tried rebuilding the library among lots of other things.

    I put a zip of the project here with all the dependancies. It should just build if anyone feels like taking a look

    http://1drv.ms/1tyvo9d

    Bryan
  • Hmm I just noticed that Im linking against libovrd.lib, but if I link against libovr.lib the assertion gets compiled out and the program seems to run :-)

    Bryan