1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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_esolution: i32,
pub h_screen_size: f32,
pub v_screen_size: f32,
pub v_screen_center: 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 Into<ffi::VrDeviceInfo> for VrDeviceInfo {
fn into(self) -> ffi::VrDeviceInfo {
unsafe { std::mem::transmute(self) }
}
}
impl Into<ffi::VrDeviceInfo> for &VrDeviceInfo {
fn into(self) -> ffi::VrDeviceInfo {
ffi::VrDeviceInfo {
hResolution: self.h_resolution,
vResolution: self.v_esolution,
hScreenSize: self.h_screen_size,
vScreenSize: self.v_screen_size,
vScreenCenter: self.v_screen_center,
eyeToScreenDistance: self.eye_to_screen_distance,
lensSeparationDistance: self.lens_separation_distance,
interpupillaryDistance: self.interpupillary_distance,
lensDistortionValues: self.lens_distortion_values,
chromaAbCorrection: self.chroma_ab_correction,
}
}
}
impl RaylibHandle {
pub fn load_vr_stereo_config(
&mut self,
_: &RaylibThread,
device: impl Into<ffi::VrDeviceInfo>,
) -> VrStereoConfig {
return VrStereoConfig(unsafe { ffi::LoadVrStereoConfig(device.into()) });
}
}