Cogs.Core
RasterizerState.h
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}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
STL namespace.
Encapsulates state for primitive rasterization in a state object.
static RasterizerState DefaultState()
Constructs a rasterizer state initialized with the default values.
bool multiSample
If multisample rasterization should be enabled. Default is true.
bool scissor
Enable scissor rect.
bool frontCounterClockwise
If counter clockwise polygon winding is used to specify front facing polygons. Default is false.
bool noDepthClip
Clamp depth value instead of clipping against near and depth planes.
CullMode cullMode
Which face culling mode to apply to primitives before rasterization.
float depthBias
Depth bias to apply to depth values after initial rasterization before depth values are written.
float depthBiasClamp
Value to clamp the depth bias to so that it may not go outside desired values even when applying slop...
float slopeScaledDepthBias
Slope scaled depth bias value controlling the depth bias value based on the area of the polygon on sc...
CullMode
Culling modes for triangle rasterization.
@ None
Do not perform any face culling.
@ Back
Cull back facing primitives.
@ Front
Cull front facing primitives.
bool wireFrame
If only wire frames should be rasterized. Default is false.