# Head Mounted Display

# Head Mounted Display

Functions for managing viewer information.

## Summary

| ### Functions ||
|---|---|
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1ga45bc64fff9319039dfc1a4b7680afb3a(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr, const int32_t eye, const https://developers.google.com/vr/reference/android-ndk/struct/gvr-vec2f#structgvr__vec2f uv_in, https://developers.google.com/vr/reference/android-ndk/struct/gvr-vec2f#structgvr__vec2f uv_out[3])` | `void` Computes the distorted point for a given point in a given eye. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1gaddf0ec0d10c90427b87257d0f1344348(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr, const int32_t eye)` | `https://developers.google.com/vr/reference/android-ndk/struct/gvr-mat4f#structgvr__mat4f` Gets the transformation matrix to convert from Head Space to Eye Space for the given eye. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1ga521073e2ee6b56435f1dcbe44e777f6a(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr)` | `const char *` Gets the name of the viewer model. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1gaf95a05d7c2e95e893deb51d6f0074557(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr)` | `int32_t` Gets the type of the viewer, as defined by gvr_viewer_type. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1gaecffd73e68a74233fd03f200ad5991f9(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr)` | `const char *` Gets the name of the viewer vendor. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1ga5e3570b005a0f76b8b7b9b650a634674(const https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr)` | `https://developers.google.com/vr/reference/android-ndk/struct/gvr-recti#structgvr__recti` Gets the window bounds. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1gac2b8fe0c95855e4f3cbd79804b0cb781(https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *gvr)` | `void` Refreshes gvr_context with the viewer profile that is stored on the device. |
| `https://developers.google.com/vr/reference/android-ndk/group/h-m-d#group___h_m_d_1gacdbc7438587f61749324bff457c7fc7e(https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1ga23df772969ac0cc13f77fffdec5c18ea *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.

<br />

| 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.

<br />

| 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.

<br />

| 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.

<br />

| 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.

<br />

| 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.

<br />

| 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.

<br />

| 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.

<br />

| 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. |