rFactor2_vk_hud/src/overlay/elements/mod.rs

49 lines
1.2 KiB
Rust
Raw Normal View History

2023-01-18 06:09:44 +00:00
mod leaderboard;
2023-01-17 11:18:53 +00:00
mod pedals;
mod radar;
2023-01-17 14:44:11 +00:00
mod watermark;
2023-01-17 11:18:53 +00:00
2023-01-18 06:09:44 +00:00
pub use leaderboard::*;
2023-01-17 11:18:53 +00:00
pub use pedals::*;
pub use radar::*;
2023-01-17 14:44:11 +00:00
pub use watermark::*;
2023-01-18 10:51:16 +00:00
#[derive(Clone)]
pub struct PositionOnlyVertex {
pub position: cgmath::Vector4<f32>,
}
impl PositionOnlyVertex {
///
/// corners[0] - bottom left
/// corners[1] - top left
/// corners[2] - top right
/// corners[3] - bottom right
///
pub fn from_2d_corners(
ortho: cgmath::Matrix4<f32>,
corners: [cgmath::Vector2<f32>; 4],
) -> [Self; 6] {
[
Self {
position: ortho * corners[0].extend(0.0).extend(1.0),
},
Self {
position: ortho * corners[1].extend(0.0).extend(1.0),
},
Self {
position: ortho * corners[2].extend(0.0).extend(1.0),
},
Self {
position: ortho * corners[2].extend(0.0).extend(1.0),
},
Self {
position: ortho * corners[3].extend(0.0).extend(1.0),
},
Self {
position: ortho * corners[0].extend(0.0).extend(1.0),
},
]
}
}