summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/value.hpp
blob: 128eff2dce868324ee7612e9f27060501f685bc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#pragma once

#include <mbgl/gl/types.hpp>
#include <mbgl/gfx/depth_mode.hpp>
#include <mbgl/gfx/stencil_mode.hpp>
#include <mbgl/gfx/color_mode.hpp>
#include <mbgl/gl/cull_face_mode.hpp>
#include <mbgl/gl/attribute.hpp>
#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/util/range.hpp>

namespace mbgl {
namespace gl {

class Context;

namespace value {

struct ClearDepth {
    using Type = float;
    static const constexpr Type Default = 1;
    static void Set(const Type&);
    static Type Get();
};

struct ClearColor {
    using Type = Color;
    static const Type Default;
    static void Set(const Type&);
    static Type Get();
};

struct ClearStencil {
    using Type = int32_t;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct StencilMask {
    using Type = uint32_t;
    static const constexpr Type Default = ~0u;
    static void Set(const Type&);
    static Type Get();
};

struct DepthMask {
    using Type = gfx::DepthMaskType;
    static const constexpr Type Default = gfx::DepthMaskType::ReadWrite;
    static void Set(const Type&);
    static Type Get();
};

struct ColorMask {
    using Type = gfx::ColorMode::Mask;
    static const constexpr Type Default = { true, true, true, true };
    static void Set(const Type&);
    static Type Get();
};

struct StencilFunc {
    struct Type {
        gfx::StencilFunctionType func;
        int32_t ref;
        uint32_t mask;
    };
    static const constexpr Type Default = { gfx::StencilMode::Always::func, 0, ~0u };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const StencilFunc::Type& a, const StencilFunc::Type& b) {
    return a.func != b.func || a.ref != b.ref || a.mask != b.mask;
}

struct StencilTest {
    using Type = bool;
    static const constexpr Type Default = false;
    static void Set(const Type&);
    static Type Get();
};

struct StencilOp {
    struct Type {
        gfx::StencilOpType sfail;
        gfx::StencilOpType dpfail;
        gfx::StencilOpType dppass;
    };
    static const constexpr Type Default = { gfx::StencilOpType::Keep, gfx::StencilOpType::Keep, gfx::StencilOpType::Keep };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const StencilOp::Type& a, const StencilOp::Type& b) {
    return a.sfail != b.sfail || a.dpfail != b.dpfail || a.dppass != b.dppass;
}

struct DepthRange {
    using Type = Range<float>;
    static const constexpr Type Default = { 0, 1 };
    static void Set(const Type&);
    static Type Get();
};

struct DepthTest {
    using Type = bool;
    static const constexpr Type Default = false;
    static void Set(const Type&);
    static Type Get();
};

struct DepthFunc {
    using Type = gfx::DepthFunctionType;
    static const constexpr Type Default = gfx::DepthFunctionType::Less;
    static void Set(const Type&);
    static Type Get();
};

struct Blend {
    using Type = bool;
    static const constexpr Type Default = true;
    static void Set(const Type&);
    static Type Get();
};

struct BlendEquation {
    using Type = gfx::ColorBlendEquationType;
    static const constexpr Type Default = gfx::ColorBlendEquationType::Add;
    static void Set(const Type&);
    static Type Get();
};

struct BlendFunc {
    struct Type {
        gfx::ColorBlendFactorType sfactor;
        gfx::ColorBlendFactorType dfactor;
    };
    static const constexpr Type Default = { gfx::ColorBlendFactorType::One, gfx::ColorBlendFactorType::Zero };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const BlendFunc::Type& a, const BlendFunc::Type& b) {
    return a.sfactor != b.sfactor || a.dfactor != b.dfactor;
}

struct BlendColor {
    using Type = Color;
    static const Type Default;
    static void Set(const Type&);
    static Type Get();
};

struct Program {
    using Type = gl::ProgramID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct LineWidth {
    using Type = float;
    static const constexpr Type Default = 1;
    static void Set(const Type&);
    static Type Get();
};

struct ActiveTextureUnit {
    using Type = TextureUnit;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct Viewport {
    struct Type {
        int32_t x;
        int32_t y;
        Size size;
    };
    static const constexpr Type Default = { 0, 0, { 0, 0 } };
    static void Set(const Type&);
    static Type Get();
};

struct ScissorTest {
    using Type = bool;
    static const constexpr Type Default = false;
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const Viewport::Type& a, const Viewport::Type& b) {
    return a.x != b.x || a.y != b.y || a.size != b.size;
}

constexpr bool operator==(const Viewport::Type& a, const Viewport::Type& b) {
    return !(a != b);
}

struct BindFramebuffer {
    using Type = FramebufferID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct BindRenderbuffer {
    using Type = RenderbufferID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct CullFace {
    using Type = CullFaceMode::CullFace;
    static const constexpr Type Default = CullFaceMode::Disable;
    static void Set(const Type&);
    static Type Get();
};

struct CullFaceSide {
    using Type = CullFaceMode::CullFaceSide;
    static const constexpr Type Default = CullFaceMode::Back;
    static void Set(const Type&);
    static Type Get();
};

struct FrontFace {
    using Type = CullFaceMode::FrontFace;
    static const constexpr Type Default = CullFaceMode::CounterClockwise;
    static void Set(const Type&);
    static Type Get();
};

struct BindTexture {
    using Type = gl::TextureID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct BindVertexBuffer {
    using Type = gl::BufferID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct BindElementBuffer {
    using Type = gl::BufferID;
    static const constexpr Type Default = 0;
    static void Set(const Type&);
    static Type Get();
};

struct BindVertexArray {
    using Type = gl::VertexArrayID;
    static const constexpr Type Default = 0;
    static void Set(const Type&, const Context&);
    static Type Get(const Context&);
};

struct VertexAttribute {
    using Type = optional<gl::AttributeBinding>;
    static const Type Default;
    static void Set(const Type&, Context&, AttributeLocation);
};

struct PixelStorePack {
    using Type = PixelStorageType;
    static const constexpr Type Default = { 4 };
    static void Set(const Type&);
    static Type Get();
};

struct PixelStoreUnpack {
    using Type = PixelStorageType;
    static const constexpr Type Default = { 4 };
    static void Set(const Type&);
    static Type Get();
};

#if not MBGL_USE_GLES2

struct PointSize {
    using Type = float;
    static const constexpr Type Default = 1;
    static void Set(const Type&);
    static Type Get();
};

struct PixelZoom {
    struct Type {
        float xfactor;
        float yfactor;
    };
    static const constexpr Type Default = { 1, 1 };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const PixelZoom::Type& a, const PixelZoom::Type& b) {
    return a.xfactor != b.xfactor || a.yfactor != b.yfactor;
}

struct RasterPos {
    struct Type {
        double x;
        double y;
        double z;
        double w;
    };
    static const constexpr Type Default = { 0, 0, 0, 1 };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const RasterPos::Type& a, const RasterPos::Type& b) {
    return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
}

struct PixelTransferDepth {
    struct Type {
        float scale;
        float bias;
    };
    static const constexpr Type Default = { 1, 0 };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const PixelTransferDepth::Type& a, const PixelTransferDepth::Type& b) {
    return a.scale != b.scale || a.bias != b.bias;
}

struct PixelTransferStencil {
    struct Type {
        int32_t shift;
        int32_t offset;
    };
    static const constexpr Type Default = { 0, 0 };
    static void Set(const Type&);
    static Type Get();
};

constexpr bool operator!=(const PixelTransferStencil::Type& a, const PixelTransferStencil::Type& b) {
    return a.shift != b.shift || a.offset != b.offset;
}

#endif // MBGL_USE_GLES2

} // namespace value
} // namespace gl
} // namespace mbgl