1 #pragma once
2 
3 #include <mbgl/gl/types.hpp>
4 #include <mbgl/gl/depth_mode.hpp>
5 #include <mbgl/gl/stencil_mode.hpp>
6 #include <mbgl/gl/color_mode.hpp>
7 #include <mbgl/gl/attribute.hpp>
8 #include <mbgl/util/color.hpp>
9 #include <mbgl/util/size.hpp>
10 #include <mbgl/util/range.hpp>
11 
12 namespace mbgl {
13 namespace gl {
14 
15 class Context;
16 
17 namespace value {
18 
19 struct ClearDepth {
20     using Type = float;
21     static const constexpr Type Default = 1;
22     static void Set(const Type&);
23     static Type Get();
24 };
25 
26 struct ClearColor {
27     using Type = Color;
28     static const Type Default;
29     static void Set(const Type&);
30     static Type Get();
31 };
32 
33 struct ClearStencil {
34     using Type = int32_t;
35     static const constexpr Type Default = 0;
36     static void Set(const Type&);
37     static Type Get();
38 };
39 
40 struct StencilMask {
41     using Type = uint32_t;
42     static const constexpr Type Default = ~0u;
43     static void Set(const Type&);
44     static Type Get();
45 };
46 
47 struct DepthMask {
48     using Type = bool;
49     static const constexpr Type Default = true;
50     static void Set(const Type&);
51     static Type Get();
52 };
53 
54 struct ColorMask {
55     using Type = ColorMode::Mask;
56     static const constexpr Type Default = { true, true, true, true };
57     static void Set(const Type&);
58     static Type Get();
59 };
60 
61 struct StencilFunc {
62     struct Type {
63         uint32_t func;
64         int32_t ref;
65         uint32_t mask;
66     };
67     static const constexpr Type Default = { StencilMode::Always::func, 0, ~0u };
68     static void Set(const Type&);
69     static Type Get();
70 };
71 
operator !=(const StencilFunc::Type & a,const StencilFunc::Type & b)72 constexpr bool operator!=(const StencilFunc::Type& a, const StencilFunc::Type& b) {
73     return a.func != b.func || a.ref != b.ref || a.mask != b.mask;
74 }
75 
76 struct StencilTest {
77     using Type = bool;
78     static const constexpr Type Default = false;
79     static void Set(const Type&);
80     static Type Get();
81 };
82 
83 struct StencilOp {
84     struct Type {
85         StencilMode::Op sfail;
86         StencilMode::Op dpfail;
87         StencilMode::Op dppass;
88     };
89     static const constexpr Type Default = { StencilMode::Keep, StencilMode::Keep, StencilMode::Keep };
90     static void Set(const Type&);
91     static Type Get();
92 };
93 
operator !=(const StencilOp::Type & a,const StencilOp::Type & b)94 constexpr bool operator!=(const StencilOp::Type& a, const StencilOp::Type& b) {
95     return a.sfail != b.sfail || a.dpfail != b.dpfail || a.dppass != b.dppass;
96 }
97 
98 struct DepthRange {
99     using Type = Range<float>;
100     static const constexpr Type Default = { 0, 1 };
101     static void Set(const Type&);
102     static Type Get();
103 };
104 
105 struct DepthTest {
106     using Type = bool;
107     static const constexpr Type Default = false;
108     static void Set(const Type&);
109     static Type Get();
110 };
111 
112 struct DepthFunc {
113     using Type = DepthMode::Function;
114     static const constexpr Type Default = DepthMode::Less;
115     static void Set(const Type&);
116     static Type Get();
117 };
118 
119 struct Blend {
120     using Type = bool;
121     static const constexpr Type Default = true;
122     static void Set(const Type&);
123     static Type Get();
124 };
125 
126 struct BlendEquation {
127     using Type = ColorMode::BlendEquation;
128     static const constexpr Type Default = ColorMode::BlendEquation::Add;
129     static void Set(const Type&);
130     static Type Get();
131 };
132 
133 struct BlendFunc {
134     struct Type {
135         ColorMode::BlendFactor sfactor;
136         ColorMode::BlendFactor dfactor;
137     };
138     static const constexpr Type Default = { ColorMode::One, ColorMode::Zero };
139     static void Set(const Type&);
140     static Type Get();
141 };
142 
operator !=(const BlendFunc::Type & a,const BlendFunc::Type & b)143 constexpr bool operator!=(const BlendFunc::Type& a, const BlendFunc::Type& b) {
144     return a.sfactor != b.sfactor || a.dfactor != b.dfactor;
145 }
146 
147 struct BlendColor {
148     using Type = Color;
149     static const Type Default;
150     static void Set(const Type&);
151     static Type Get();
152 };
153 
154 struct Program {
155     using Type = gl::ProgramID;
156     static const constexpr Type Default = 0;
157     static void Set(const Type&);
158     static Type Get();
159 };
160 
161 struct LineWidth {
162     using Type = float;
163     static const constexpr Type Default = 1;
164     static void Set(const Type&);
165     static Type Get();
166 };
167 
168 struct ActiveTextureUnit {
169     using Type = TextureUnit;
170     static const constexpr Type Default = 0;
171     static void Set(const Type&);
172     static Type Get();
173 };
174 
175 struct Viewport {
176     struct Type {
177         int32_t x;
178         int32_t y;
179         Size size;
180     };
181     static const constexpr Type Default = { 0, 0, { 0, 0 } };
182     static void Set(const Type&);
183     static Type Get();
184 };
185 
186 struct ScissorTest {
187     using Type = bool;
188     static const constexpr Type Default = false;
189     static void Set(const Type&);
190     static Type Get();
191 };
192 
operator !=(const Viewport::Type & a,const Viewport::Type & b)193 constexpr bool operator!=(const Viewport::Type& a, const Viewport::Type& b) {
194     return a.x != b.x || a.y != b.y || a.size != b.size;
195 }
196 
operator ==(const Viewport::Type & a,const Viewport::Type & b)197 constexpr bool operator==(const Viewport::Type& a, const Viewport::Type& b) {
198     return !(a != b);
199 }
200 
201 struct BindFramebuffer {
202     using Type = FramebufferID;
203     static const constexpr Type Default = 0;
204     static void Set(const Type&);
205     static Type Get();
206 };
207 
208 struct BindRenderbuffer {
209     using Type = RenderbufferID;
210     static const constexpr Type Default = 0;
211     static void Set(const Type&);
212     static Type Get();
213 };
214 
215 struct BindTexture {
216     using Type = gl::TextureID;
217     static const constexpr Type Default = 0;
218     static void Set(const Type&);
219     static Type Get();
220 };
221 
222 struct BindVertexBuffer {
223     using Type = gl::BufferID;
224     static const constexpr Type Default = 0;
225     static void Set(const Type&);
226     static Type Get();
227 };
228 
229 struct BindElementBuffer {
230     using Type = gl::BufferID;
231     static const constexpr Type Default = 0;
232     static void Set(const Type&);
233     static Type Get();
234 };
235 
236 struct BindVertexArray {
237     using Type = gl::VertexArrayID;
238     static const constexpr Type Default = 0;
239     static void Set(const Type&, const Context&);
240     static Type Get(const Context&);
241 };
242 
243 struct VertexAttribute {
244     using Type = optional<gl::AttributeBinding>;
245     static const Type Default;
246     static void Set(const Type&, Context&, AttributeLocation);
247 };
248 
249 struct PixelStorePack {
250     using Type = PixelStorageType;
251     static const constexpr Type Default = { 4 };
252     static void Set(const Type&);
253     static Type Get();
254 };
255 
256 struct PixelStoreUnpack {
257     using Type = PixelStorageType;
258     static const constexpr Type Default = { 4 };
259     static void Set(const Type&);
260     static Type Get();
261 };
262 
263 #if not MBGL_USE_GLES2
264 
265 struct PointSize {
266     using Type = float;
267     static const constexpr Type Default = 1;
268     static void Set(const Type&);
269     static Type Get();
270 };
271 
272 struct PixelZoom {
273     struct Type {
274         float xfactor;
275         float yfactor;
276     };
277     static const constexpr Type Default = { 1, 1 };
278     static void Set(const Type&);
279     static Type Get();
280 };
281 
operator !=(const PixelZoom::Type & a,const PixelZoom::Type & b)282 constexpr bool operator!=(const PixelZoom::Type& a, const PixelZoom::Type& b) {
283     return a.xfactor != b.xfactor || a.yfactor != b.yfactor;
284 }
285 
286 struct RasterPos {
287     struct Type {
288         double x;
289         double y;
290         double z;
291         double w;
292     };
293     static const constexpr Type Default = { 0, 0, 0, 1 };
294     static void Set(const Type&);
295     static Type Get();
296 };
297 
operator !=(const RasterPos::Type & a,const RasterPos::Type & b)298 constexpr bool operator!=(const RasterPos::Type& a, const RasterPos::Type& b) {
299     return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
300 }
301 
302 struct PixelTransferDepth {
303     struct Type {
304         float scale;
305         float bias;
306     };
307     static const constexpr Type Default = { 1, 0 };
308     static void Set(const Type&);
309     static Type Get();
310 };
311 
operator !=(const PixelTransferDepth::Type & a,const PixelTransferDepth::Type & b)312 constexpr bool operator!=(const PixelTransferDepth::Type& a, const PixelTransferDepth::Type& b) {
313     return a.scale != b.scale || a.bias != b.bias;
314 }
315 
316 struct PixelTransferStencil {
317     struct Type {
318         int32_t shift;
319         int32_t offset;
320     };
321     static const constexpr Type Default = { 0, 0 };
322     static void Set(const Type&);
323     static Type Get();
324 };
325 
operator !=(const PixelTransferStencil::Type & a,const PixelTransferStencil::Type & b)326 constexpr bool operator!=(const PixelTransferStencil::Type& a, const PixelTransferStencil::Type& b) {
327     return a.shift != b.shift || a.offset != b.offset;
328 }
329 
330 #endif // MBGL_USE_GLES2
331 
332 } // namespace value
333 } // namespace gl
334 } // namespace mbgl
335