Cogs.Rendering
Loading...
Searching...
No Matches
RasterizerState.h
Go to the documentation of this file.
1#pragma once
2
3namespace Cogs
4{
12 {
15 {
17 Front = 0,
21 None
22 };
23
26
29
32
35
37 float depthBias;
38
41
44
46 bool scissor;
47
49 bool noDepthClip = false;
50
55 {
56 static RasterizerState rasterizerState = {
57 false, // No wire frame, filled primitives
58 RasterizerState::None, // No face culling
59 false, // Clockwise polygon winding order
60 true, // Enable multi sampling
61 0.0f, // No depth bias
62 0.0f, // No slope scaled depth bias
63 0.0f, // Do not clamp the depth bias
64 false, // No scissor rect
65 false // Depth clip enabled.
66 };
67
68 return rasterizerState;
69 }
70 };
71}
72
73namespace std
74{
78 template<>
79 struct hash<Cogs::RasterizerState>
80 {
81 std::size_t operator()(const Cogs::RasterizerState & rs) const
82 {
83 unsigned int simple =
84 rs.cullMode |
85 (rs.wireFrame ? 4 : 0) |
86 (rs.frontCounterClockwise ? 8 : 0) |
87 (rs.multiSample ? 16 : 0) |
88 (rs.scissor ? 32 : 0) |
89 (rs.noDepthClip ? 64 : 0);
90 return
91 std::hash<int>()(simple) ^
92 (13 * std::hash<float>()(rs.depthBias) ^
93 (13 * std::hash<float>()(rs.slopeScaledDepthBias) ^
94 (13 * std::hash<float>()(rs.depthBiasClamp))));
95 }
96 };
97
101 template<>
102 struct equal_to<Cogs::RasterizerState>
103 {
104 bool operator()(const Cogs::RasterizerState & lhs, const Cogs::RasterizerState & rhs) const
105 {
106 return
107 (lhs.wireFrame == rhs.wireFrame) &&
108 (lhs.cullMode == rhs.cullMode) &&
110 (lhs.multiSample == rhs.multiSample) &&
111 (lhs.depthBias == rhs.depthBias) &&
113 (lhs.depthBiasClamp == rhs.depthBiasClamp) &&
114 (lhs.scissor == rhs.scissor) &&
115 (lhs.noDepthClip == rhs.noDepthClip);
116 }
117 };
118}
Definition: Base.h:24
STL namespace.
Encapsulates state for primitive rasterization in a state object.
Definition: RasterizerState.h:12
static RasterizerState DefaultState()
Constructs a rasterizer state initialized with the default values.
Definition: RasterizerState.h:54
bool multiSample
If multisample rasterization should be enabled. Default is true.
Definition: RasterizerState.h:34
bool scissor
Enable scissor rect.
Definition: RasterizerState.h:46
bool frontCounterClockwise
If counter clockwise polygon winding is used to specify front facing polygons. Default is false.
Definition: RasterizerState.h:31
bool noDepthClip
Clamp depth value instead of clipping against near and depth planes.
Definition: RasterizerState.h:49
CullMode cullMode
Which face culling mode to apply to primitives before rasterization.
Definition: RasterizerState.h:28
float depthBias
Depth bias to apply to depth values after initial rasterization before depth values are written.
Definition: RasterizerState.h:37
float depthBiasClamp
Value to clamp the depth bias to so that it may not go outside desired values even when applying slop...
Definition: RasterizerState.h:43
float slopeScaledDepthBias
Slope scaled depth bias value controlling the depth bias value based on the area of the polygon on sc...
Definition: RasterizerState.h:40
CullMode
Culling modes for triangle rasterization.
Definition: RasterizerState.h:15
@ None
Do not perform any face culling.
Definition: RasterizerState.h:21
@ Back
Cull back facing primitives.
Definition: RasterizerState.h:19
@ Front
Cull front facing primitives.
Definition: RasterizerState.h:17
bool wireFrame
If only wire frames should be rasterized. Default is false.
Definition: RasterizerState.h:25
bool operator()(const Cogs::RasterizerState &lhs, const Cogs::RasterizerState &rhs) const
Definition: RasterizerState.h:104
std::size_t operator()(const Cogs::RasterizerState &rs) const
Definition: RasterizerState.h:81