Module rovr::render [-] [+] [src]

Methods for directly working with rendering.

Example

End-to-end rendering looks something like this:

let hmd = Context::new().unwrap()
    .build_hmd()
    .track(&TrackingOptions::with_all())
    .build().unwrap();
let (w, h) = hmd.resolution();

// <create a window with an OpenGL context based on resolution>
// <create a render target; see rovr::target for details>


// This is unsafe because of the lifetime of native_window. If the window is closed before this
// render context is destroyed, bad things may happen!
let rc = hmd.render_to(&render_target).unwrap();
let (w_left, h_left) = rc.target_texture_size(&Eye::Left);
let (w_right, h_right) = rc.target_texture_size(&Eye::Right);

// <create framebuffers with backing textures with these dimensions>
// <grab their OpenGL ids>

let binding = rc.create_binding(left_tex_id, right_tex_id);
loop {
    let frame = Frame::new(&rc, &binding);
    // draw to framebuffers; frame will finish at end of loop body
}

Structs

Frame

A single frame. All OpenGL rendering to both eyes' frame buffers should happen while this object is alive. When going out of scope, the Oculus SDK will complete the rendering process, including post-processing and any necessary buffer swapping.

FrameEyePose

A single eye's pose for a frame.

RenderContext

An active Oculus rendering context associated with an HMD. Only OpenGL is supported. This provides access to the basic metadata necessary to prepare OpenGL framebuffers for drawing.

TextureBinding

Texture binding, representing a registered pair of OpenGL textures that should serve as render targets for per-eye viewpoints. Create with RenderContext::create_binding()

Type Definitions

Matrix4

A 4x4 matrix, by convention in column-major format.

Quaternion

A quaternion. The first element of the tuple is the w value, and the array contains x, y, and z values.

Vector3

A 3-dimensional vector, with (in order) x, y, and z components.