Oculus SDL2 Examples
This is a set of minimal cross-platform example applications for the Oculus Rift written in C++ and depending only on SDL2, the Oculus VR SDK, and GLEW. As of this writing, the code compiles against Oculus SDK 0.4.3 beta.
These examples share a simple SDL2 application framework that provides an OpenGL 3.2 Core Profile and an FPS-style interaction. Their modular design enables easy reuse and the license permits you to copy them for any purpose.
As the Oculus SDK continues to evolve, the documentation lags behind the implementation.
OVR_SDL2_app is a by-the-book implementation of an Oculus app, as described by the Developer's Guide, but a great deal of digging through the headers was necessary to complete the job. That's all encoded here.
This code also makes good use of SDL2, particularly the new game controller API, which presents all inputs as though they came from an XBox controller. The SDL2 event loop also delivers controller connection and disconnection events, which this code uses supports completely.
Keyboard-mouse navigation uses
WASD to move and the mouse to turn.
Space moves up and
C moves down.
Gamepad navigation moves with the left stick and turns with the right. Button A moves up and button B moves down.
OVR_SDL2_obj takes a list of OBJ input files on the command line.
OVR_SDL2_appimplements a cross-platform VR application base class using SDL2 and the Oculus SDK.
OVR_SDL2_appto implement first-person-style navigation supporting both gamepad and keyboard-mouse inputs.
OVR_SDL2_navto implement a tiny room demo.
OVR_SDL2_navto implement a Wavefront OBJ viewer application.
GLFundamentalsimplements the necessary OpenGL functionality including matrix mathematics and shader handling.
GLFramebufferencapsulates an OpenGL framebuffer object.
Windows executables may be downloaded here.
A Visual Studio 2013 solution is provided. It contains projects for
OVR_SDL2_obj. Check the "VC++ Directories" settings in each project to ensure that SDL2, the Oculus SDK, and GLEW can be located.
If building a project from scratch, link
The OS X build does not require GLEW.
Install the SDL2 framework to
/Library/Frameworks and follow the Linux directions...
Makefile to ensure that the following definition gives the correct location for the Oculus SDK.