October 15, 2019 update:
  • The Daydream View VR headset is no longer available for purchase. However, developers can continue to use the existing Google VR SDK to update and distribute their apps to the Google Play Store, and make them available to users in the Daydream app.

Head Mounted Display

Functions for managing viewer information.

Summary

Functions

gvr_compute_distorted_point(const gvr_context *gvr, const int32_t eye, const gvr_vec2f uv_in, gvr_vec2f uv_out[3])
void
Computes the distorted point for a given point in a given eye.
gvr_get_eye_from_head_matrix(const gvr_context *gvr, const int32_t eye)
Gets the transformation matrix to convert from Head Space to Eye Space for the given eye.
gvr_get_viewer_model(const gvr_context *gvr)
const char *
Gets the name of the viewer model.
gvr_get_viewer_type(const gvr_context *gvr)
int32_t
Gets the type of the viewer, as defined by gvr_viewer_type.
gvr_get_viewer_vendor(const gvr_context *gvr)
const char *
Gets the name of the viewer vendor.
gvr_get_window_bounds(const gvr_context *gvr)
Gets the window bounds.
gvr_refresh_viewer_profile(gvr_context *gvr)
void
Refreshes gvr_context with the viewer profile that is stored on the device.
gvr_set_default_viewer_profile(gvr_context *gvr, const char *viewer_profile_uri)
bool
Sets the default viewer profile specified by viewer_profile_uri.

Functions

gvr_compute_distorted_point

void gvr_compute_distorted_point(
  const gvr_context *gvr,
  const int32_t eye,
  const gvr_vec2f uv_in,
  gvr_vec2f uv_out[3]
)

Computes the distorted point for a given point in a given eye.

The distortion inverts the optical distortion caused by the lens for the eye. Due to chromatic aberration, the distortion is different for each color channel.

Details
Parameters
gvr
Pointer to the gvr instance which will do the computing.
eye
The gvr_eye type (left or right).
uv_in
A point in screen eye Viewport Space in [0,1]^2 with (0, 0) in the lower left corner of the eye's viewport and (1, 1) in the upper right corner of the eye's viewport.
uv_out
A pointer to an array of (at least) 3 elements, with each element being a Point2f representing a point in render texture eye Viewport Space in [0,1]^2 with (0, 0) in the lower left corner of the eye's viewport and (1, 1) in the upper right corner of the eye's viewport. uv_out[0] is the corrected position of uv_in for the red channel uv_out[1] is the corrected position of uv_in for the green channel uv_out[2] is the corrected position of uv_in for the blue channel

gvr_get_eye_from_head_matrix

gvr_mat4f gvr_get_eye_from_head_matrix(
  const gvr_context *gvr,
  const int32_t eye
)

Gets the transformation matrix to convert from Head Space to Eye Space for the given eye.

Details
Parameters
gvr
Pointer to the gvr instance from which to get the matrix.
eye
Selected eye type.
Returns
Transformation matrix from Head Space to selected Eye Space.

gvr_get_viewer_model

const char * gvr_get_viewer_model(
  const gvr_context *gvr
)

Gets the name of the viewer model.

Details
Parameters
gvr
Pointer to the gvr instance from which to get the name.
Returns
A pointer to the model name. May be NULL if no viewer is paired. WARNING: This method guarantees the validity of the returned pointer only until the next use of the gvr context. The string should be copied immediately if persistence is required.

gvr_get_viewer_type

int32_t gvr_get_viewer_type(
  const gvr_context *gvr
)

Gets the type of the viewer, as defined by gvr_viewer_type.

Details
Parameters
gvr
Pointer to the gvr instance from which to get the viewer type.
Returns
The gvr_viewer_type of the currently paired viewer.

gvr_get_viewer_vendor

const char * gvr_get_viewer_vendor(
  const gvr_context *gvr
)

Gets the name of the viewer vendor.

Details
Parameters
gvr
Pointer to the gvr instance from which to get the vendor.
Returns
A pointer to the vendor name. May be NULL if no viewer is paired. WARNING: This method guarantees the validity of the returned pointer only until the next use of the gvr context. The string should be copied immediately if persistence is required.

gvr_get_window_bounds

gvr_recti gvr_get_window_bounds(
  const gvr_context *gvr
)

Gets the window bounds.

Details
Parameters
gvr
Pointer to the gvr instance from which to get the bounds.
Returns
Window bounds in physical pixels.

gvr_refresh_viewer_profile

void gvr_refresh_viewer_profile(
  gvr_context *gvr
)

Refreshes gvr_context with the viewer profile that is stored on the device.

If it can not find the viewer profile, nothing will happen.

Details
Parameters
gvr
Pointer to the gvr instance to refresh the profile on.

gvr_set_default_viewer_profile

bool gvr_set_default_viewer_profile(
  gvr_context *gvr,
  const char *viewer_profile_uri
)

Sets the default viewer profile specified by viewer_profile_uri.

The viewer_profile_uri that is passed in will be ignored if a valid viewer profile has already been stored on the device that the app is running on.

Note: This function has the potential of blocking for up to 30 seconds for each redirect if a shortened URI is passed in as argument. It will try to unroll the shortened URI for a maximum number of 5 times if the redirect continues. In that case, it is recommended to create a separate thread to call this function so that other tasks like rendering will not be blocked on this. The blocking can be avoided if a standard URI is passed in.

Details
Parameters
gvr
Pointer to the gvr instance which to set the profile on.
viewer_profile_uri
A string that contains either the shortened URI or the standard URI representing the viewer profile that the app should be using. If the valid viewer profile can be found on the device, the URI that is passed in will be ignored and nothing will happen. Otherwise, gvr will look for the viewer profile specified by viewer_profile_uri, and it will be stored if found. Also, the values will be applied to gvr. A valid standard URI can be generated from this page: https://www.google.com/get/cardboard/viewerprofilegenerator/
Returns
True if the viewer profile specified by viewer_profile_uri was successfully stored and applied, false otherwise.