use crate::core::{RaylibHandle, RaylibThread};
use crate::ffi;
make_thin_wrapper!(
VrStereoConfig,
ffi::VrStereoConfig,
ffi::UnloadVrStereoConfig
);
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct VrDeviceInfo {
pub h_resolution: i32,
pub v_resolution: i32,
pub h_screen_size: f32,
pub v_screen_size: f32,
pub eye_to_screen_distance: f32,
pub lens_separation_distance: f32,
pub interpupillary_distance: f32,
pub lens_distortion_values: [f32; 4],
pub chroma_ab_correction: [f32; 4],
}
impl From<ffi::VrDeviceInfo> for VrDeviceInfo {
fn from(v: ffi::VrDeviceInfo) -> VrDeviceInfo {
unsafe { std::mem::transmute(v) }
}
}
impl From<VrDeviceInfo> for ffi::VrDeviceInfo {
fn from(v: VrDeviceInfo) -> Self {
unsafe { std::mem::transmute(v) }
}
}
impl From<&VrDeviceInfo> for ffi::VrDeviceInfo {
fn from(v: &VrDeviceInfo) -> Self {
ffi::VrDeviceInfo {
hResolution: v.h_resolution, vResolution: v.v_resolution, hScreenSize: v.h_screen_size, vScreenSize: v.v_screen_size, eyeToScreenDistance: v.eye_to_screen_distance, lensSeparationDistance: v.lens_separation_distance, interpupillaryDistance: v.interpupillary_distance, lensDistortionValues: v.lens_distortion_values, chromaAbCorrection: v.chroma_ab_correction, }
}
}
impl RaylibHandle {
#[inline]
#[must_use]
pub fn load_vr_stereo_config(
&mut self,
_: &RaylibThread,
device: impl Into<ffi::VrDeviceInfo>,
) -> VrStereoConfig {
VrStereoConfig(unsafe { ffi::LoadVrStereoConfig(device.into()) })
}
}