#[derive(Debug, Copy, Clone)]
pub struct RenderStates {
pub write_mask: WriteMask,
pub depth_test: DepthTestType,
pub blend: Option<BlendParameters>,
}
impl Default for RenderStates {
fn default() -> Self {
Self {
write_mask: WriteMask::default(),
depth_test: DepthTestType::Less,
blend: None,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum CullType {
None,
Back,
Front,
FrontAndBack,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum DepthTestType {
Never,
Less,
Equal,
LessOrEqual,
Greater,
NotEqual,
GreaterOrEqual,
Always,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct WriteMask {
pub red: bool,
pub green: bool,
pub blue: bool,
pub alpha: bool,
pub depth: bool,
}
impl WriteMask {
pub const COLOR_AND_DEPTH: Self = Self {
red: true,
green: true,
blue: true,
alpha: true,
depth: true,
};
pub const COLOR: Self = Self {
red: true,
green: true,
blue: true,
alpha: true,
depth: false,
};
pub const DEPTH: Self = Self {
red: false,
green: false,
blue: false,
alpha: false,
depth: true,
};
pub const NONE: Self = Self {
red: false,
green: false,
blue: false,
alpha: false,
depth: false,
};
}
impl Default for WriteMask {
fn default() -> Self {
Self::COLOR_AND_DEPTH
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct BlendParameters {
pub source_rgb_multiplier: BlendMultiplierType,
pub source_alpha_multiplier: BlendMultiplierType,
pub destination_rgb_multiplier: BlendMultiplierType,
pub destination_alpha_multiplier: BlendMultiplierType,
pub rgb_equation: BlendEquationType,
pub alpha_equation: BlendEquationType,
}
impl BlendParameters {
pub const TRANSPARENCY: Self = Self {
source_rgb_multiplier: BlendMultiplierType::SrcAlpha,
source_alpha_multiplier: BlendMultiplierType::One,
destination_rgb_multiplier: BlendMultiplierType::OneMinusSrcAlpha,
destination_alpha_multiplier: BlendMultiplierType::Zero,
rgb_equation: BlendEquationType::Add,
alpha_equation: BlendEquationType::Add,
};
pub const ADD: Self = Self {
source_rgb_multiplier: BlendMultiplierType::One,
source_alpha_multiplier: BlendMultiplierType::One,
destination_rgb_multiplier: BlendMultiplierType::One,
destination_alpha_multiplier: BlendMultiplierType::One,
rgb_equation: BlendEquationType::Add,
alpha_equation: BlendEquationType::Add,
};
}
impl Default for BlendParameters {
fn default() -> Self {
Self::TRANSPARENCY
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum BlendMultiplierType {
Zero,
One,
SrcColor,
OneMinusSrcColor,
DstColor,
OneMinusDstColor,
SrcAlpha,
OneMinusSrcAlpha,
DstAlpha,
OneMinusDstAlpha,
SrcAlphaSaturate,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum BlendEquationType {
Add,
Subtract,
ReverseSubtract,
Max,
Min,
}