H3D API  2.4.1
Public Member Functions | List of all members
OculusRiftHandler Class Reference

The OculusRiftHandler class provides support for the Oculus Rift VR device. More...

#include <H3D/OculusRiftHandler.h>

Public Member Functions

 OculusRiftHandler ()
 Constructor.
 
 ~OculusRiftHandler ()
 Destructor.
 
bool isInitialized ()
 
bool initVR ()
 Initializes the connection to the Oculus Rift. More...
 
bool initVRBuffers (int window_width, int window_height)
 Initializes the OpenGL buffers to use for rendering. More...
 
void onRenderStart ()
 Should be called in the beginning of each frame. More...
 
void onEyeRender (int eye_index, H3D::Matrix4f &view_matrix, H3D::Matrix4f &projection_matrix)
 Should be called just before rendering the specified eye. More...
 
void onEyeRenderFinish (int eye_index)
 Should be called when rendering for the specified eye is done. More...
 
void submitFrame ()
 Should be called when all rendering is done to submit the current frame to the HMD display.
 
void blitMirror (ovrEyeType num_eyes=ovrEye_Count, int offset=0)
 Should be called after submitFrame to transfer the data to the back buffer (this is to update the view in the normal render window)
 
void destroyVR ()
 Cleanup everything.
 
void recenterTracking ()
 Recenter the HMD tracking so that the current view direction is center,.
 
const ovrSizei getResolution () const
 Gets the resolution of the HMD display.
 
H3D::Matrix4f getEyeMVPMatrix (int eye_index) const
 Gets the view-projection matrix for an eye.
 
void setMSAA (bool val)
 Toggle multi-sample anti-aliasing.
 
bool MSAAEnabled () const
 Get current status of multi-sample anti-aliasing. More...
 

Detailed Description

The OculusRiftHandler class provides support for the Oculus Rift VR device.

It provides convenience functions to initialize and render OpenGL content to the OculusRift display. It is based on the MinimumOpenGL code by Krzysztof Kondrak that can be found at https://github.com/kondrak/oculusvr_samples.

Current SDK version supported is 1.3.

To integrate with your solution

Member Function Documentation

◆ initVR()

bool OculusRiftHandler::initVR ( )

Initializes the connection to the Oculus Rift.

Returns
true if successful, false if failed.

Referenced by H3D::H3DWindowNode::render().

◆ initVRBuffers()

bool OculusRiftHandler::initVRBuffers ( int  window_width,
int  window_height 
)

Initializes the OpenGL buffers to use for rendering.

Parameters
window_widthThe width of the buffer to use (in pixels).
window_heightThe height of the buffer to use (in pixels).
Returns
true if successful, false if failed.

Referenced by H3D::H3DWindowNode::render().

◆ isInitialized()

bool OculusRiftHandler::isInitialized ( )
inline
Returns
true if Oculus has been successfully initialized with initVR, false otherwise.

Referenced by H3D::H3DWindowNode::render().

◆ MSAAEnabled()

bool OculusRiftHandler::MSAAEnabled ( ) const
inline

Get current status of multi-sample anti-aliasing.

Returns
true if enabled, false if disabled.

◆ onEyeRender()

void OculusRiftHandler::onEyeRender ( int  eye_index,
H3D::Matrix4f &  view_matrix,
H3D::Matrix4f &  projection_matrix 
)

Should be called just before rendering the specified eye.


Matrices set in the ooutput parameters should be used in the modelview and projection matrix for the render.

Parameters
eye_indexThe index of the eye (normally 0 for left and 1 for right)
view_matrixOutput for the view matrix to use for the eye.
projection_matrixOutput for the projection matrix to use for the eye.

Referenced by H3D::H3DWindowNode::render().

◆ onEyeRenderFinish()

void OculusRiftHandler::onEyeRenderFinish ( int  eye_index)

Should be called when rendering for the specified eye is done.

Parameters
eye_indexThe index of the eye (normally 0 for left and 1 for right)

Referenced by H3D::H3DWindowNode::render().

◆ onRenderStart()

void OculusRiftHandler::onRenderStart ( )

Should be called in the beginning of each frame.

Saves the tracker data from the HMD to be used in the current frame.

Referenced by H3D::H3DWindowNode::render().


The documentation for this class was generated from the following files: