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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/// Internal namespace.
mod private
{
use crate::*;
/// A builder for creating a `web_sys::GpuStencilFaceState`.
#[ derive( Default, Clone ) ]
pub struct StencilFaceState
{
/// The comparison function used for the stencil test.
///
/// The stencil test compares a reference value against the value in the stencil
/// buffer. If this test passes, the stencil operations are executed.
///
/// Defaults to `GpuCompareFunction::Always`.
compare : Option< GpuCompareFunction >,
/// The stencil operation to perform if the depth test fails.
///
/// This is only relevant if the stencil test passes but the subsequent depth
/// test fails.
///
/// Defaults to `GpuStencilOperation::Keep`.
depth_fail_op : Option< GpuStencilOperation >,
/// The stencil operation to perform if both the stencil and depth tests pass.
///
/// Defaults to `GpuStencilOperation::Keep`.
pass_op : Option< GpuStencilOperation >,
/// The stencil operation to perform if the stencil test fails.
///
/// Defaults to `GpuStencilOperation::Keep`.
fail_op : Option< GpuStencilOperation >
}
impl StencilFaceState
{
/// Creates a new `StencilFaceState` with default values.
pub fn new() -> Self
{
Self::default()
}
/// Sets the stencil comparison function.
pub fn compare( mut self, compare : GpuCompareFunction ) -> Self
{
self.compare = Some( compare );
self
}
/// Sets the operation for when the depth test fails.
pub fn depth_fail_op( mut self, op : GpuStencilOperation ) -> Self
{
self.depth_fail_op = Some( op );
self
}
/// Sets the operation for when both stencil and depth tests pass.
pub fn pass_op( mut self, op : GpuStencilOperation ) -> Self
{
self.pass_op = Some( op );
self
}
/// Sets the operation for when the stencil test fails.
pub fn fail_op( mut self, op : GpuStencilOperation ) -> Self
{
self.fail_op = Some( op );
self
}
}
impl From< StencilFaceState > for web_sys::GpuStencilFaceState
{
fn from( value: StencilFaceState ) -> Self
{
let state = web_sys::GpuStencilFaceState::new();
if let Some( v ) = value.compare { state.set_compare( v ); }
if let Some( v ) = value.depth_fail_op { state.set_depth_fail_op( v ); }
if let Some( v ) = value.pass_op { state.set_pass_op( v ); }
if let Some( v ) = value.fail_op { state.set_fail_op( v ); }
state
}
}
}
crate::mod_interface!
{
exposed use
{
StencilFaceState
};
}