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
// Copied from `scripts/static/`

use std::fmt::*;
use std::mem;
use utils::vk_traits::*;

#[doc(hidden)]
#[repr(C)]
#[derive(Copy, Clone)]
pub union RawVkClearColorValue {
    float32: [f32; 4],
    int32: [i32; 4],
    uint32: [u32; 4]
}

/// Wrapper for [VkClearColorValue](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkClearColorValue.html)
#[derive(Debug, Clone)]
pub enum VkClearColorValue {
    F([f32; 4]),
    I([i32; 4]),
    U([u32; 4])
}

impl Debug for RawVkClearColorValue {
    fn fmt(&self, f: &mut Formatter) -> Result {
        write!(f, "{:?}", unsafe { self.float32 } )
    }
}

impl VkWrappedType<RawVkClearColorValue> for VkClearColorValue {
    fn vk_to_raw(value: &VkClearColorValue, dst: &mut RawVkClearColorValue) {
        match *value {
            VkClearColorValue::F(array) => {
                *dst = RawVkClearColorValue { float32: array };
            },
            VkClearColorValue::I(array) => {
                *dst = RawVkClearColorValue { int32: array };
            },
            VkClearColorValue::U(array) => {
                *dst = RawVkClearColorValue { uint32: array };
            }
        }
    }
}

impl Default for VkClearColorValue {
    fn default() -> VkClearColorValue {
        VkClearColorValue::U([0; 4])
    }
}