Cogs.Rendering
Loading...
Searching...
No Matches
DepthStencilState.h
Go to the documentation of this file.
1#pragma once
2
3namespace Cogs
4{
13 {
24 {
26 Never = 0,
40 Always
41 };
42
45
48
55
60 {
61 DepthStencilState depthStencilState = {
62 true, // Depth test enabled.
63 true, // Depth writes enabled.
64 DepthStencilState::Less // "Less" comparison function.
65 };
66
67 return depthStencilState;
68 }
69 };
70}
71
72namespace std
73{
77 template<>
78 struct hash<Cogs::DepthStencilState>
79 {
80 std::size_t operator()(const Cogs::DepthStencilState & ds) const
81 {
82 return std::hash<int>()(ds.depthFunction | (ds.depthEnabled ? 8 : 0) | (ds.writeEnabled ? 16 : 0));
83 }
84 };
85
89 template<>
90 struct equal_to<Cogs::DepthStencilState>
91 {
92 bool operator()(const Cogs::DepthStencilState & lhs, const Cogs::DepthStencilState & rhs) const
93 {
94 return lhs.depthEnabled == rhs.depthEnabled && lhs.writeEnabled == rhs.writeEnabled && lhs.depthFunction == rhs.depthFunction;
95 }
96 };
97}
Definition: Base.h:24
STL namespace.
Encapsulates state for depth buffer usage and stencil buffer usage in a state object.
Definition: DepthStencilState.h:13
DepthFunction
Depth functions to apply when determining object visibility based on its depth test.
Definition: DepthStencilState.h:24
@ Never
Never evaluates to true. When using this, all objects will fail depth testing.
Definition: DepthStencilState.h:26
@ GreaterOrEqual
Greater or equal depth.
Definition: DepthStencilState.h:34
@ NotEqual
Depth not equal evaluates to true.
Definition: DepthStencilState.h:38
@ Equal
Equal depth.
Definition: DepthStencilState.h:32
@ Greater
Greater depth.
Definition: DepthStencilState.h:36
@ Less
Less depth.
Definition: DepthStencilState.h:28
@ Always
Always evaluates to true.
Definition: DepthStencilState.h:40
@ LessOrEqual
Less or equal depth.
Definition: DepthStencilState.h:30
bool depthEnabled
If depth testing is enabled/disabled. Default is true.
Definition: DepthStencilState.h:44
DepthFunction depthFunction
The depth function to use for depth testing.
Definition: DepthStencilState.h:54
static DepthStencilState DefaultState()
Constructs a depth stencil state object initialized with the default values.
Definition: DepthStencilState.h:59
bool writeEnabled
If writes to the depth buffer are enabled/disabled. Default is true.
Definition: DepthStencilState.h:47
bool operator()(const Cogs::DepthStencilState &lhs, const Cogs::DepthStencilState &rhs) const
Definition: DepthStencilState.h:92
std::size_t operator()(const Cogs::DepthStencilState &ds) const
Definition: DepthStencilState.h:80