#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Comparison {
Never,
Always,
Equal,
NotEqual,
Less,
LessOrEqual,
Greater,
GreaterOrEqual,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Write {
On,
Off,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct StencilTest {
pub comparison: Comparison,
pub reference: u8,
pub mask: u8,
}
impl StencilTest {
pub fn new(comparison: Comparison, reference: u8, mask: u8) -> Self {
Self {
comparison,
reference,
mask,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct StencilOperations {
pub depth_passes_stencil_fails: StencilOp,
pub depth_fails_stencil_passes: StencilOp,
pub depth_stencil_pass: StencilOp,
}
impl StencilOperations {
pub fn new() -> Self {
Self::default()
}
pub fn on_depth_passes_stencil_fails(self, op: StencilOp) -> Self {
Self {
depth_passes_stencil_fails: op,
..self
}
}
pub fn on_depth_fails_stencil_passes(self, op: StencilOp) -> Self {
Self {
depth_fails_stencil_passes: op,
..self
}
}
pub fn on_depth_stencil_pass(self, op: StencilOp) -> Self {
Self {
depth_stencil_pass: op,
..self
}
}
}
impl Default for StencilOperations {
fn default() -> Self {
Self {
depth_passes_stencil_fails: StencilOp::Keep,
depth_fails_stencil_passes: StencilOp::Keep,
depth_stencil_pass: StencilOp::Keep,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum StencilOp {
Keep,
Zero,
Replace,
Increment,
IncrementWrap,
Decrement,
DecrementWrap,
Invert,
}