1use crate::{ffi, math::Matrix};
2
3use static_assertions::{assert_eq_align, assert_eq_size};
4
5#[repr(C)]
7#[derive(Clone, Debug, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct VrDeviceInfo {
10 pub horizontal_resolution: u32,
12 pub vertical_resolution: u32,
14 pub horizontal_screen_size: f32,
16 pub vertical_screen_size: f32,
18 pub screen_center_v: f32,
20 pub eye_to_screen_distance: f32,
22 pub lens_separation_distance: f32,
24 pub interpupillary_distance: f32,
26 pub lens_distortion_values: [f32; 4],
28 pub chroma_ab_correction: [f32; 4],
30}
31
32assert_eq_size!(VrDeviceInfo, ffi::VrDeviceInfo);
33assert_eq_align!(VrDeviceInfo, ffi::VrDeviceInfo);
34
35impl From<VrDeviceInfo> for ffi::VrDeviceInfo {
36 #[inline]
37 fn from(val: VrDeviceInfo) -> Self {
38 unsafe { std::mem::transmute(val) }
39 }
40}
41
42impl From<ffi::VrDeviceInfo> for VrDeviceInfo {
43 #[inline]
44 fn from(value: ffi::VrDeviceInfo) -> Self {
45 unsafe { std::mem::transmute(value) }
46 }
47}
48
49#[repr(C)]
51#[derive(Clone, Debug, PartialEq)]
52#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
53pub struct VrStereoConfig {
54 pub projection: [Matrix; 2],
56 pub view_offset: [Matrix; 2],
58 pub left_lens_center: [f32; 2],
60 pub right_lens_center: [f32; 2],
62 pub left_screen_center: [f32; 2],
64 pub right_screen_center: [f32; 2],
66 pub scale: [f32; 2],
68 pub scale_in: [f32; 2],
70}
71
72impl VrStereoConfig {
73 pub fn load(device: VrDeviceInfo) -> Self {
75 assert_eq!(crate::RAYLIB_VERSION, "4.5");
77
78 unsafe { ffi::LoadVrStereoConfig(device.into()).into() }
79 }
80}
81
82assert_eq_size!(VrStereoConfig, ffi::VrStereoConfig);
83assert_eq_align!(VrStereoConfig, ffi::VrStereoConfig);
84
85impl From<VrStereoConfig> for ffi::VrStereoConfig {
86 #[inline]
87 fn from(val: VrStereoConfig) -> Self {
88 assert_eq!(crate::RAYLIB_VERSION, "4.5");
90
91 unsafe { std::mem::transmute(val) }
92 }
93}
94
95impl From<ffi::VrStereoConfig> for VrStereoConfig {
96 #[inline]
97 fn from(value: ffi::VrStereoConfig) -> Self {
98 assert_eq!(crate::RAYLIB_VERSION, "4.5");
100
101 unsafe { std::mem::transmute(value) }
102 }
103}
104
105impl Drop for VrStereoConfig {
106 #[inline]
107 fn drop(&mut self) {
108 assert_eq!(crate::RAYLIB_VERSION, "4.5");
110
111 }
113}