1use crate::align::{Align4, Align8};
2use crate::uniform::{Std140, Uniform};
3
4macro_rules! impl_scalar {
5 ($type:ty : $align:tt) => {
6 unsafe impl Std140 for $type {}
7
8 impl Uniform for $type {
9 type Align = $align;
10 type Std140 = $type;
11
12 fn std140(&self) -> $type {
13 *self
14 }
15 }
16 };
17}
18
19#[derive(Clone, Copy, Debug, Default, PartialOrd, PartialEq, Ord, Eq, Hash)]
21pub struct boolean(u32);
22impl_scalar!(boolean: Align4);
23
24impl boolean {
25 pub fn new(value: bool) -> Self {
27 value.into()
28 }
29}
30
31impl From<bool> for boolean {
32 fn from(value: bool) -> Self {
33 boolean(value as u32)
34 }
35}
36
37impl From<boolean> for bool {
38 fn from(value: boolean) -> Self {
39 value.0 != 0
40 }
41}
42
43pub type int = i32;
45impl_scalar!(int: Align4);
46
47pub type uint = u32;
49impl_scalar!(uint: Align4);
50
51pub type float = f32;
53impl_scalar!(float: Align4);
54
55pub type double = f64;
57impl_scalar!(double: Align8);