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
|
// Copyright (C) Intel Corp. 2017. All Rights Reserved.
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// The above copyright notice and this permission notice (including the
// next paragraph) shall be included in all copies or substantial
// portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// **********************************************************************/
// * Authors:
// * Mark Janes <mark.a.janes@intel.com>
// **********************************************************************/
#include "glframe_state_enums.hpp"
#include <assert.h>
#include <GL/glext.h>
#include <map>
#include <string>
#include <vector>
uint32_t
glretrace::state_name_to_enum(const std::string &value) {
static const std::map<std::string, uint32_t> names {
{"GL_ALWAYS", GL_ALWAYS},
{"GL_BACK", GL_BACK},
{"GL_BLEND", GL_BLEND},
{"GL_BLEND_COLOR", GL_BLEND_COLOR},
{"GL_BLEND_DST", GL_BLEND_DST},
{"GL_BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA},
{"GL_BLEND_DST_RGB", GL_BLEND_DST_RGB},
{"GL_BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA},
{"GL_BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB},
{"GL_BLEND_SRC", GL_BLEND_SRC},
{"GL_BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA},
{"GL_BLEND_SRC_RGB", GL_BLEND_SRC_RGB},
{"GL_CCW", GL_CCW},
{"GL_CW", GL_CW},
{"GL_COLOR_CLEAR_VALUE", GL_COLOR_CLEAR_VALUE},
{"GL_COLOR_WRITEMASK", GL_COLOR_WRITEMASK},
{"GL_CONSTANT_ALPHA", GL_CONSTANT_ALPHA},
{"GL_CONSTANT_COLOR", GL_CONSTANT_COLOR},
{"GL_CULL_FACE", GL_CULL_FACE},
{"GL_CULL_FACE_MODE", GL_CULL_FACE_MODE},
{"GL_DEPTH_CLEAR_VALUE", GL_DEPTH_CLEAR_VALUE},
{"GL_DEPTH_FUNC", GL_DEPTH_FUNC},
{"GL_DEPTH_RANGE", GL_DEPTH_RANGE},
{"GL_DEPTH_TEST", GL_DEPTH_TEST},
{"GL_DEPTH_WRITEMASK", GL_DEPTH_WRITEMASK},
{"GL_DITHER", GL_DITHER},
{"GL_DST_ALPHA", GL_DST_ALPHA},
{"GL_DST_COLOR", GL_DST_COLOR},
{"GL_EQUAL", GL_EQUAL},
{"GL_FRONT", GL_FRONT},
{"GL_FRONT_FACE", GL_FRONT_FACE},
{"GL_FRONT_AND_BACK", GL_FRONT_AND_BACK},
{"GL_FUNC_ADD", GL_FUNC_ADD},
{"GL_FUNC_REVERSE_SUBTRACT", GL_FUNC_REVERSE_SUBTRACT},
{"GL_FUNC_SUBTRACT", GL_FUNC_SUBTRACT},
{"GL_GEQUAL", GL_GEQUAL},
{"GL_GREATER", GL_GREATER},
{"GL_LEQUAL", GL_LEQUAL},
{"GL_LESS", GL_LESS},
{"GL_LINE_SMOOTH", GL_LINE_SMOOTH},
{"GL_LINE_WIDTH", GL_LINE_WIDTH},
{"GL_MAX", GL_MAX},
{"GL_MIN", GL_MIN},
{"GL_NEVER", GL_NEVER},
{"GL_NOTEQUAL", GL_NOTEQUAL},
{"GL_ONE", GL_ONE},
{"GL_ONE_MINUS_CONSTANT_ALPHA", GL_ONE_MINUS_CONSTANT_ALPHA},
{"GL_ONE_MINUS_CONSTANT_COLOR", GL_ONE_MINUS_CONSTANT_COLOR},
{"GL_ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA},
{"GL_ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR},
{"GL_ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA},
{"GL_ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR},
{"GL_POLYGON_OFFSET_FACTOR", GL_POLYGON_OFFSET_FACTOR},
{"GL_POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL},
{"GL_POLYGON_OFFSET_UNITS", GL_POLYGON_OFFSET_UNITS},
{"GL_SRC_ALPHA", GL_SRC_ALPHA},
{"GL_SRC_ALPHA_SATURATE", GL_SRC_ALPHA_SATURATE},
{"GL_SRC_COLOR", GL_SRC_COLOR},
{"GL_ZERO", GL_ZERO},
{"false", 0},
{"true", 1},
};
const auto i = names.find(value);
if (i == names.end())
return GL_INVALID_ENUM;
return i->second;
}
std::string
glretrace::state_enum_to_name(GLint value) {
static const std::map<uint32_t, std::string> names {
{GL_ALWAYS, "GL_ALWAYS"},
{GL_BACK, "GL_BACK"},
{GL_BLEND, "GL_BLEND"},
{GL_BLEND_COLOR, "GL_BLEND_COLOR"},
{GL_BLEND_DST, "GL_BLEND_DST"},
{GL_BLEND_DST_ALPHA, "GL_BLEND_DST_ALPHA"},
{GL_BLEND_DST_RGB, "GL_BLEND_DST_RGB"},
{GL_BLEND_EQUATION_ALPHA, "GL_BLEND_EQUATION_ALPHA"},
{GL_BLEND_EQUATION_RGB, "GL_BLEND_EQUATION_RGB"},
{GL_BLEND_SRC, "GL_BLEND_SRC"},
{GL_BLEND_SRC_ALPHA, "GL_BLEND_SRC_ALPHA"},
{GL_BLEND_SRC_RGB, "GL_BLEND_SRC_RGB"},
{GL_CCW, "GL_CCW"},
{GL_CW, "GL_CW"},
{GL_COLOR_CLEAR_VALUE, "GL_COLOR_CLEAR_VALUE"},
{GL_COLOR_WRITEMASK, "GL_COLOR_WRITEMASK"},
{GL_CONSTANT_ALPHA, "GL_CONSTANT_ALPHA"},
{GL_CONSTANT_COLOR, "GL_CONSTANT_COLOR"},
{GL_CULL_FACE, "GL_CULL_FACE"},
{GL_CULL_FACE_MODE, "GL_CULL_FACE_MODE"},
{GL_DEPTH_CLEAR_VALUE, "GL_DEPTH_CLEAR_VALUE"},
{GL_DEPTH_FUNC, "GL_DEPTH_FUNC"},
{GL_DEPTH_RANGE, "GL_DEPTH_RANGE"},
{GL_DEPTH_TEST, "GL_DEPTH_TEST"},
{GL_DEPTH_WRITEMASK, "GL_DEPTH_WRITEMASK"},
{GL_DITHER, "GL_DITHER"},
{GL_DST_ALPHA, "GL_DST_ALPHA"},
{GL_DST_COLOR, "GL_DST_COLOR"},
{GL_EQUAL, "GL_EQUAL"},
{GL_FRONT, "GL_FRONT"},
{GL_FRONT_FACE, "GL_FRONT_FACE"},
{GL_FRONT_AND_BACK, "GL_FRONT_AND_BACK"},
{GL_FUNC_ADD, "GL_FUNC_ADD"},
{GL_FUNC_REVERSE_SUBTRACT, "GL_FUNC_REVERSE_SUBTRACT"},
{GL_FUNC_SUBTRACT, "GL_FUNC_SUBTRACT"},
{GL_GEQUAL, "GL_GEQUAL"},
{GL_GREATER, "GL_GREATER"},
{GL_LEQUAL, "GL_LEQUAL"},
{GL_LESS, "GL_LESS"},
{GL_LINE_SMOOTH, "GL_LINE_SMOOTH"},
{GL_LINE_WIDTH, "GL_LINE_WIDTH"},
{GL_MAX, "GL_MAX"},
{GL_MIN, "GL_MIN"},
{GL_NEVER, "GL_NEVER"},
{GL_NOTEQUAL, "GL_NOTEQUAL"},
{GL_ONE, "GL_ONE"},
{GL_ONE_MINUS_CONSTANT_ALPHA, "GL_ONE_MINUS_CONSTANT_ALPHA"},
{GL_ONE_MINUS_CONSTANT_COLOR, "GL_ONE_MINUS_CONSTANT_COLOR"},
{GL_ONE_MINUS_DST_ALPHA, "GL_ONE_MINUS_DST_ALPHA"},
{GL_ONE_MINUS_DST_COLOR, "GL_ONE_MINUS_DST_COLOR"},
{GL_ONE_MINUS_SRC_ALPHA, "GL_ONE_MINUS_SRC_ALPHA"},
{GL_ONE_MINUS_SRC_COLOR, "GL_ONE_MINUS_SRC_COLOR"},
{GL_POLYGON_OFFSET_FACTOR, "GL_POLYGON_OFFSET_FACTOR"},
{GL_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL"},
{GL_POLYGON_OFFSET_UNITS, "GL_POLYGON_OFFSET_UNITS"},
{GL_SRC_ALPHA, "GL_SRC_ALPHA"},
{GL_SRC_ALPHA_SATURATE, "GL_SRC_ALPHA_SATURATE"},
{GL_SRC_COLOR, "GL_SRC_COLOR"},
{GL_ZERO, "GL_ZERO"},
};
const auto i = names.find(value);
if (i == names.end()) {
assert(false);
return "GL_INVALID_ENUM";
}
return i->second;
}
std::vector<std::string>
glretrace::state_name_to_choices(const std::string &n) {
switch (state_name_to_enum(n)) {
case GL_BLEND:
case GL_COLOR_WRITEMASK:
case GL_CULL_FACE:
case GL_DEPTH_TEST:
case GL_DEPTH_WRITEMASK:
case GL_DITHER:
case GL_LINE_SMOOTH:
case GL_POLYGON_OFFSET_FILL:
return {"true", "false"};
case GL_BLEND_DST:
case GL_BLEND_DST_ALPHA:
case GL_BLEND_DST_RGB:
case GL_BLEND_SRC:
case GL_BLEND_SRC_ALPHA:
case GL_BLEND_SRC_RGB:
return {"GL_ZERO",
"GL_ONE",
"GL_SRC_COLOR",
"GL_ONE_MINUS_SRC_COLOR",
"GL_DST_COLOR",
"GL_ONE_MINUS_DST_COLOR",
"GL_SRC_ALPHA",
"GL_ONE_MINUS_SRC_ALPHA",
"GL_DST_ALPHA",
"GL_ONE_MINUS_DST_ALPHA",
"GL_CONSTANT_COLOR",
"GL_ONE_MINUS_CONSTANT_COLOR",
"GL_CONSTANT_ALPHA",
"GL_ONE_MINUS_CONSTANT_ALPHA",
"GL_SRC_ALPHA_SATURATE"
};
case GL_BLEND_EQUATION_ALPHA:
case GL_BLEND_EQUATION_RGB:
return {"GL_FUNC_ADD",
"GL_FUNC_SUBTRACT",
"GL_FUNC_REVERSE_SUBTRACT",
"GL_MIN",
"GL_MAX"
};
case GL_CULL_FACE_MODE:
return {"GL_FRONT", "GL_BACK", "GL_FRONT_AND_BACK"};
case GL_DEPTH_FUNC:
return {"GL_NEVER", "GL_LESS", "GL_EQUAL", "GL_LEQUAL",
"GL_GREATER", "GL_NOTEQUAL", "GL_GEQUAL", "GL_ALWAYS"};
case GL_FRONT_FACE:
return {"GL_CW", "GL_CCW"};
case GL_INVALID_ENUM:
assert(false);
default:
return {};
}
}
std::vector<std::string>
glretrace::state_name_to_indices(const std::string &n) {
switch (state_name_to_enum(n)) {
case GL_COLOR_WRITEMASK:
return {"Red Enabled", "Green Enabled", "Blue Enabled", "Alpha Enabled"};
case GL_BLEND_COLOR:
case GL_COLOR_CLEAR_VALUE:
return {"Red", "Green", "Blue", "Alpha"};
case GL_DEPTH_RANGE:
return {"Near", "Far"};
case GL_BLEND:
case GL_CULL_FACE:
case GL_DEPTH_TEST:
case GL_DEPTH_WRITEMASK:
case GL_DITHER:
case GL_LINE_SMOOTH:
case GL_POLYGON_OFFSET_FILL:
return {"Enabled"};
default:
return {};
}
}
|