Cogs.Core
SamplerState.h
1#pragma once
2
3namespace Cogs
4{
12 {
15 {
24
25 // Provided for size comparisons.
26 AddressMode_Size,
27 };
28
31 {
36
41
42 // Provided for size comparisons.
43 FilterMode_Size,
44 };
45
48 {
49 Never,
50 Less,
51 Equal,
52 LessEqual,
53 Greater,
54 NotEqual,
55 GreaterEqual,
56 Always,
57
58 // Provided for size comparisons.
59 ComparisonFunction_Size,
60 };
61
68
71
74
76 unsigned int maxAnisotropy;
77
80 float borderColor[4];
81
86 static SamplerState samplerState = {
87 Wrap,
88 Wrap,
89 Wrap,
91 Never,
92 1,
93 { 0, 0, 0, 1 }
94 };
95
96 return samplerState;
97 }
98 };
99}
100
101namespace std
102{
106 template<>
107 struct hash<Cogs::SamplerState>
108 {
109 std::size_t operator()(const Cogs::SamplerState & state) const
110 {
111 static std::hash<size_t> hashFunction;
112
113 size_t result = hashFunction(static_cast<size_t>(state.addressModeS));
114 result = result * 16777619 + hashFunction(static_cast<size_t>(state.addressModeT));
115 result = result * 16777619 + hashFunction(static_cast<size_t>(state.addressModeW));
116 result = result * 16777619 + hashFunction(static_cast<size_t>(state.filter));
117 result = result * 16777619 + hashFunction(static_cast<size_t>(state.comparisonFunction));
118 result = result * 16777619 + hashFunction(static_cast<size_t>(state.maxAnisotropy));
119
120 return result;
121 }
122 };
123
127 template<>
128 struct equal_to<Cogs::SamplerState>
129 {
130 bool operator()(const Cogs::SamplerState & lhs, const Cogs::SamplerState & rhs) const
131 {
132 return lhs.addressModeS == rhs.addressModeS &&
133 lhs.addressModeT == rhs.addressModeT &&
134 lhs.addressModeW == rhs.addressModeW &&
135 lhs.filter == rhs.filter &&
137 lhs.maxAnisotropy == rhs.maxAnisotropy;
138 }
139 };
140}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
STL namespace.
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
ComparisonFunction comparisonFunction
Specifies the comparison function to use when applying a comparison sampler.
Definition: SamplerState.h:73
unsigned int maxAnisotropy
Specifies the maximum number of anisotropic samples to use when sampling a texture.
Definition: SamplerState.h:76
static SamplerState & DefaultState()
Constructs a sampler state initialized with the default values.
Definition: SamplerState.h:85
AddressMode addressModeW
Specifies the addressing mode along the W axis in texture coordinate space.
Definition: SamplerState.h:67
ComparisonFunction
Comparison functions applied when sampling depth buffers using comparison filters.
Definition: SamplerState.h:48
AddressMode addressModeS
Specifies the addressing mode along the S axis in texture coordinate space.
Definition: SamplerState.h:63
AddressMode
Addressing modes to use when sampling textures.
Definition: SamplerState.h:15
@ Clamp
Texture coordinates are clamped to the [0, 1] range.
Definition: SamplerState.h:17
@ Border
Texture color is set to the border color when outside [0, 1] range.
Definition: SamplerState.h:23
@ Wrap
Texture coordinates automatically wrap around to [0, 1] range.
Definition: SamplerState.h:19
@ Mirror
Texture coordinates are mirrored when outside [0, 1] range.
Definition: SamplerState.h:21
float borderColor[4]
Definition: SamplerState.h:80
FilterMode
Filter modes to specify how texture data is treated when sampled.
Definition: SamplerState.h:31
@ ComparisonMinMagMipPoint
Comparison filter for depth sample comparisons using point sampling.
Definition: SamplerState.h:38
@ ComparisonMinMagMipLinear
Comparison filter for depth sample comparisons using linear interpolation sampling.
Definition: SamplerState.h:40
@ MinMagMipPoint
Point sampling for both minification and magnification.
Definition: SamplerState.h:33
@ MinMagMipLinear
Linear sampling for both minification and magnification.
Definition: SamplerState.h:35
FilterMode filter
Specifies the filter to use for texture sampling.
Definition: SamplerState.h:70
AddressMode addressModeT
Specifies the addressing mode along the T axis in texture coordinate space.
Definition: SamplerState.h:65