Skip to main content

vulkan_rust_sys/
clear_value.rs

1//! Safe constructors for [`ClearValue`] and [`ClearColorValue`] unions.
2
3use crate::structs::{ClearColorValue, ClearDepthStencilValue, ClearValue};
4
5impl ClearColorValue {
6    /// Create from RGBA float values.
7    #[inline]
8    pub const fn from_float32(rgba: [f32; 4]) -> Self {
9        Self { float32: rgba }
10    }
11
12    /// Create from RGBA signed integer values.
13    #[inline]
14    pub const fn from_int32(rgba: [i32; 4]) -> Self {
15        Self { int32: rgba }
16    }
17
18    /// Create from RGBA unsigned integer values.
19    #[inline]
20    pub const fn from_uint32(rgba: [u32; 4]) -> Self {
21        Self { uint32: rgba }
22    }
23}
24
25impl ClearValue {
26    /// Create a color clear value from RGBA floats.
27    #[inline]
28    pub const fn color_f32(rgba: [f32; 4]) -> Self {
29        Self {
30            color: ClearColorValue::from_float32(rgba),
31        }
32    }
33
34    /// Create a color clear value from RGBA signed integers.
35    #[inline]
36    pub const fn color_i32(rgba: [i32; 4]) -> Self {
37        Self {
38            color: ClearColorValue::from_int32(rgba),
39        }
40    }
41
42    /// Create a color clear value from RGBA unsigned integers.
43    #[inline]
44    pub const fn color_u32(rgba: [u32; 4]) -> Self {
45        Self {
46            color: ClearColorValue::from_uint32(rgba),
47        }
48    }
49
50    /// Create a depth/stencil clear value.
51    #[inline]
52    pub const fn depth_stencil(depth: f32, stencil: u32) -> Self {
53        Self {
54            depth_stencil: ClearDepthStencilValue { depth, stencil },
55        }
56    }
57}