1// GENERATED FILE - DO NOT EDIT.
2// Generated by gen_packed_gl_enums.py using data from packed_gl_enums.json.
3//
4// Copyright 2019 The ANGLE Project Authors. All rights reserved.
5// Use of this source code is governed by a BSD-style license that can be
6// found in the LICENSE file.
7//
8// PackedGLEnums_autogen.cpp:
9// Implements ANGLE-specific enums classes for GLenums and functions operating
10// on them.
11
12#include "common/PackedGLEnums_autogen.h"
13#include "common/debug.h"
14
15namespace gl
16{
17
18template <>
19AlphaTestFunc FromGLenum<AlphaTestFunc>(GLenum from)
20{
21 switch (from)
22 {
23 case GL_ALWAYS:
24 return AlphaTestFunc::AlwaysPass;
25 case GL_EQUAL:
26 return AlphaTestFunc::Equal;
27 case GL_GEQUAL:
28 return AlphaTestFunc::Gequal;
29 case GL_GREATER:
30 return AlphaTestFunc::Greater;
31 case GL_LEQUAL:
32 return AlphaTestFunc::Lequal;
33 case GL_LESS:
34 return AlphaTestFunc::Less;
35 case GL_NEVER:
36 return AlphaTestFunc::Never;
37 case GL_NOTEQUAL:
38 return AlphaTestFunc::NotEqual;
39 default:
40 return AlphaTestFunc::InvalidEnum;
41 }
42}
43
44GLenum ToGLenum(AlphaTestFunc from)
45{
46 switch (from)
47 {
48 case AlphaTestFunc::AlwaysPass:
49 return GL_ALWAYS;
50 case AlphaTestFunc::Equal:
51 return GL_EQUAL;
52 case AlphaTestFunc::Gequal:
53 return GL_GEQUAL;
54 case AlphaTestFunc::Greater:
55 return GL_GREATER;
56 case AlphaTestFunc::Lequal:
57 return GL_LEQUAL;
58 case AlphaTestFunc::Less:
59 return GL_LESS;
60 case AlphaTestFunc::Never:
61 return GL_NEVER;
62 case AlphaTestFunc::NotEqual:
63 return GL_NOTEQUAL;
64 default:
65 UNREACHABLE();
66 return 0;
67 }
68}
69
70template <>
71BufferBinding FromGLenum<BufferBinding>(GLenum from)
72{
73 switch (from)
74 {
75 case GL_ARRAY_BUFFER:
76 return BufferBinding::Array;
77 case GL_ATOMIC_COUNTER_BUFFER:
78 return BufferBinding::AtomicCounter;
79 case GL_COPY_READ_BUFFER:
80 return BufferBinding::CopyRead;
81 case GL_COPY_WRITE_BUFFER:
82 return BufferBinding::CopyWrite;
83 case GL_DISPATCH_INDIRECT_BUFFER:
84 return BufferBinding::DispatchIndirect;
85 case GL_DRAW_INDIRECT_BUFFER:
86 return BufferBinding::DrawIndirect;
87 case GL_ELEMENT_ARRAY_BUFFER:
88 return BufferBinding::ElementArray;
89 case GL_PIXEL_PACK_BUFFER:
90 return BufferBinding::PixelPack;
91 case GL_PIXEL_UNPACK_BUFFER:
92 return BufferBinding::PixelUnpack;
93 case GL_SHADER_STORAGE_BUFFER:
94 return BufferBinding::ShaderStorage;
95 case GL_TRANSFORM_FEEDBACK_BUFFER:
96 return BufferBinding::TransformFeedback;
97 case GL_UNIFORM_BUFFER:
98 return BufferBinding::Uniform;
99 default:
100 return BufferBinding::InvalidEnum;
101 }
102}
103
104GLenum ToGLenum(BufferBinding from)
105{
106 switch (from)
107 {
108 case BufferBinding::Array:
109 return GL_ARRAY_BUFFER;
110 case BufferBinding::AtomicCounter:
111 return GL_ATOMIC_COUNTER_BUFFER;
112 case BufferBinding::CopyRead:
113 return GL_COPY_READ_BUFFER;
114 case BufferBinding::CopyWrite:
115 return GL_COPY_WRITE_BUFFER;
116 case BufferBinding::DispatchIndirect:
117 return GL_DISPATCH_INDIRECT_BUFFER;
118 case BufferBinding::DrawIndirect:
119 return GL_DRAW_INDIRECT_BUFFER;
120 case BufferBinding::ElementArray:
121 return GL_ELEMENT_ARRAY_BUFFER;
122 case BufferBinding::PixelPack:
123 return GL_PIXEL_PACK_BUFFER;
124 case BufferBinding::PixelUnpack:
125 return GL_PIXEL_UNPACK_BUFFER;
126 case BufferBinding::ShaderStorage:
127 return GL_SHADER_STORAGE_BUFFER;
128 case BufferBinding::TransformFeedback:
129 return GL_TRANSFORM_FEEDBACK_BUFFER;
130 case BufferBinding::Uniform:
131 return GL_UNIFORM_BUFFER;
132 default:
133 UNREACHABLE();
134 return 0;
135 }
136}
137
138template <>
139BufferUsage FromGLenum<BufferUsage>(GLenum from)
140{
141 switch (from)
142 {
143 case GL_DYNAMIC_COPY:
144 return BufferUsage::DynamicCopy;
145 case GL_DYNAMIC_DRAW:
146 return BufferUsage::DynamicDraw;
147 case GL_DYNAMIC_READ:
148 return BufferUsage::DynamicRead;
149 case GL_STATIC_COPY:
150 return BufferUsage::StaticCopy;
151 case GL_STATIC_DRAW:
152 return BufferUsage::StaticDraw;
153 case GL_STATIC_READ:
154 return BufferUsage::StaticRead;
155 case GL_STREAM_COPY:
156 return BufferUsage::StreamCopy;
157 case GL_STREAM_DRAW:
158 return BufferUsage::StreamDraw;
159 case GL_STREAM_READ:
160 return BufferUsage::StreamRead;
161 default:
162 return BufferUsage::InvalidEnum;
163 }
164}
165
166GLenum ToGLenum(BufferUsage from)
167{
168 switch (from)
169 {
170 case BufferUsage::DynamicCopy:
171 return GL_DYNAMIC_COPY;
172 case BufferUsage::DynamicDraw:
173 return GL_DYNAMIC_DRAW;
174 case BufferUsage::DynamicRead:
175 return GL_DYNAMIC_READ;
176 case BufferUsage::StaticCopy:
177 return GL_STATIC_COPY;
178 case BufferUsage::StaticDraw:
179 return GL_STATIC_DRAW;
180 case BufferUsage::StaticRead:
181 return GL_STATIC_READ;
182 case BufferUsage::StreamCopy:
183 return GL_STREAM_COPY;
184 case BufferUsage::StreamDraw:
185 return GL_STREAM_DRAW;
186 case BufferUsage::StreamRead:
187 return GL_STREAM_READ;
188 default:
189 UNREACHABLE();
190 return 0;
191 }
192}
193
194template <>
195ClientVertexArrayType FromGLenum<ClientVertexArrayType>(GLenum from)
196{
197 switch (from)
198 {
199 case GL_COLOR_ARRAY:
200 return ClientVertexArrayType::Color;
201 case GL_NORMAL_ARRAY:
202 return ClientVertexArrayType::Normal;
203 case GL_POINT_SIZE_ARRAY_OES:
204 return ClientVertexArrayType::PointSize;
205 case GL_TEXTURE_COORD_ARRAY:
206 return ClientVertexArrayType::TextureCoord;
207 case GL_VERTEX_ARRAY:
208 return ClientVertexArrayType::Vertex;
209 default:
210 return ClientVertexArrayType::InvalidEnum;
211 }
212}
213
214GLenum ToGLenum(ClientVertexArrayType from)
215{
216 switch (from)
217 {
218 case ClientVertexArrayType::Color:
219 return GL_COLOR_ARRAY;
220 case ClientVertexArrayType::Normal:
221 return GL_NORMAL_ARRAY;
222 case ClientVertexArrayType::PointSize:
223 return GL_POINT_SIZE_ARRAY_OES;
224 case ClientVertexArrayType::TextureCoord:
225 return GL_TEXTURE_COORD_ARRAY;
226 case ClientVertexArrayType::Vertex:
227 return GL_VERTEX_ARRAY;
228 default:
229 UNREACHABLE();
230 return 0;
231 }
232}
233
234template <>
235CullFaceMode FromGLenum<CullFaceMode>(GLenum from)
236{
237 switch (from)
238 {
239 case GL_BACK:
240 return CullFaceMode::Back;
241 case GL_FRONT:
242 return CullFaceMode::Front;
243 case GL_FRONT_AND_BACK:
244 return CullFaceMode::FrontAndBack;
245 default:
246 return CullFaceMode::InvalidEnum;
247 }
248}
249
250GLenum ToGLenum(CullFaceMode from)
251{
252 switch (from)
253 {
254 case CullFaceMode::Back:
255 return GL_BACK;
256 case CullFaceMode::Front:
257 return GL_FRONT;
258 case CullFaceMode::FrontAndBack:
259 return GL_FRONT_AND_BACK;
260 default:
261 UNREACHABLE();
262 return 0;
263 }
264}
265
266template <>
267FilterMode FromGLenum<FilterMode>(GLenum from)
268{
269 switch (from)
270 {
271 case GL_NEAREST:
272 return FilterMode::Nearest;
273 case GL_LINEAR:
274 return FilterMode::Linear;
275 case GL_NEAREST_MIPMAP_NEAREST:
276 return FilterMode::NearestMipmapNearest;
277 case GL_NEAREST_MIPMAP_LINEAR:
278 return FilterMode::NearestMipmapLinear;
279 case GL_LINEAR_MIPMAP_LINEAR:
280 return FilterMode::LinearMipmapLinear;
281 default:
282 return FilterMode::InvalidEnum;
283 }
284}
285
286GLenum ToGLenum(FilterMode from)
287{
288 switch (from)
289 {
290 case FilterMode::Nearest:
291 return GL_NEAREST;
292 case FilterMode::Linear:
293 return GL_LINEAR;
294 case FilterMode::NearestMipmapNearest:
295 return GL_NEAREST_MIPMAP_NEAREST;
296 case FilterMode::NearestMipmapLinear:
297 return GL_NEAREST_MIPMAP_LINEAR;
298 case FilterMode::LinearMipmapLinear:
299 return GL_LINEAR_MIPMAP_LINEAR;
300 default:
301 UNREACHABLE();
302 return 0;
303 }
304}
305
306template <>
307FogMode FromGLenum<FogMode>(GLenum from)
308{
309 switch (from)
310 {
311 case GL_EXP:
312 return FogMode::Exp;
313 case GL_EXP2:
314 return FogMode::Exp2;
315 case GL_LINEAR:
316 return FogMode::Linear;
317 default:
318 return FogMode::InvalidEnum;
319 }
320}
321
322GLenum ToGLenum(FogMode from)
323{
324 switch (from)
325 {
326 case FogMode::Exp:
327 return GL_EXP;
328 case FogMode::Exp2:
329 return GL_EXP2;
330 case FogMode::Linear:
331 return GL_LINEAR;
332 default:
333 UNREACHABLE();
334 return 0;
335 }
336}
337
338template <>
339GraphicsResetStatus FromGLenum<GraphicsResetStatus>(GLenum from)
340{
341 switch (from)
342 {
343 case GL_NO_ERROR:
344 return GraphicsResetStatus::NoError;
345 case GL_GUILTY_CONTEXT_RESET:
346 return GraphicsResetStatus::GuiltyContextReset;
347 case GL_INNOCENT_CONTEXT_RESET:
348 return GraphicsResetStatus::InnocentContextReset;
349 case GL_UNKNOWN_CONTEXT_RESET:
350 return GraphicsResetStatus::UnknownContextReset;
351 default:
352 return GraphicsResetStatus::InvalidEnum;
353 }
354}
355
356GLenum ToGLenum(GraphicsResetStatus from)
357{
358 switch (from)
359 {
360 case GraphicsResetStatus::NoError:
361 return GL_NO_ERROR;
362 case GraphicsResetStatus::GuiltyContextReset:
363 return GL_GUILTY_CONTEXT_RESET;
364 case GraphicsResetStatus::InnocentContextReset:
365 return GL_INNOCENT_CONTEXT_RESET;
366 case GraphicsResetStatus::UnknownContextReset:
367 return GL_UNKNOWN_CONTEXT_RESET;
368 default:
369 UNREACHABLE();
370 return 0;
371 }
372}
373
374template <>
375HandleType FromGLenum<HandleType>(GLenum from)
376{
377 switch (from)
378 {
379 case GL_HANDLE_TYPE_OPAQUE_FD_EXT:
380 return HandleType::OpaqueFd;
381 default:
382 return HandleType::InvalidEnum;
383 }
384}
385
386GLenum ToGLenum(HandleType from)
387{
388 switch (from)
389 {
390 case HandleType::OpaqueFd:
391 return GL_HANDLE_TYPE_OPAQUE_FD_EXT;
392 default:
393 UNREACHABLE();
394 return 0;
395 }
396}
397
398template <>
399HintSetting FromGLenum<HintSetting>(GLenum from)
400{
401 switch (from)
402 {
403 case GL_DONT_CARE:
404 return HintSetting::DontCare;
405 case GL_FASTEST:
406 return HintSetting::Fastest;
407 case GL_NICEST:
408 return HintSetting::Nicest;
409 default:
410 return HintSetting::InvalidEnum;
411 }
412}
413
414GLenum ToGLenum(HintSetting from)
415{
416 switch (from)
417 {
418 case HintSetting::DontCare:
419 return GL_DONT_CARE;
420 case HintSetting::Fastest:
421 return GL_FASTEST;
422 case HintSetting::Nicest:
423 return GL_NICEST;
424 default:
425 UNREACHABLE();
426 return 0;
427 }
428}
429
430template <>
431LightParameter FromGLenum<LightParameter>(GLenum from)
432{
433 switch (from)
434 {
435 case GL_AMBIENT:
436 return LightParameter::Ambient;
437 case GL_AMBIENT_AND_DIFFUSE:
438 return LightParameter::AmbientAndDiffuse;
439 case GL_CONSTANT_ATTENUATION:
440 return LightParameter::ConstantAttenuation;
441 case GL_DIFFUSE:
442 return LightParameter::Diffuse;
443 case GL_LINEAR_ATTENUATION:
444 return LightParameter::LinearAttenuation;
445 case GL_POSITION:
446 return LightParameter::Position;
447 case GL_QUADRATIC_ATTENUATION:
448 return LightParameter::QuadraticAttenuation;
449 case GL_SPECULAR:
450 return LightParameter::Specular;
451 case GL_SPOT_CUTOFF:
452 return LightParameter::SpotCutoff;
453 case GL_SPOT_DIRECTION:
454 return LightParameter::SpotDirection;
455 case GL_SPOT_EXPONENT:
456 return LightParameter::SpotExponent;
457 default:
458 return LightParameter::InvalidEnum;
459 }
460}
461
462GLenum ToGLenum(LightParameter from)
463{
464 switch (from)
465 {
466 case LightParameter::Ambient:
467 return GL_AMBIENT;
468 case LightParameter::AmbientAndDiffuse:
469 return GL_AMBIENT_AND_DIFFUSE;
470 case LightParameter::ConstantAttenuation:
471 return GL_CONSTANT_ATTENUATION;
472 case LightParameter::Diffuse:
473 return GL_DIFFUSE;
474 case LightParameter::LinearAttenuation:
475 return GL_LINEAR_ATTENUATION;
476 case LightParameter::Position:
477 return GL_POSITION;
478 case LightParameter::QuadraticAttenuation:
479 return GL_QUADRATIC_ATTENUATION;
480 case LightParameter::Specular:
481 return GL_SPECULAR;
482 case LightParameter::SpotCutoff:
483 return GL_SPOT_CUTOFF;
484 case LightParameter::SpotDirection:
485 return GL_SPOT_DIRECTION;
486 case LightParameter::SpotExponent:
487 return GL_SPOT_EXPONENT;
488 default:
489 UNREACHABLE();
490 return 0;
491 }
492}
493
494template <>
495LogicalOperation FromGLenum<LogicalOperation>(GLenum from)
496{
497 switch (from)
498 {
499 case GL_AND:
500 return LogicalOperation::And;
501 case GL_AND_INVERTED:
502 return LogicalOperation::AndInverted;
503 case GL_AND_REVERSE:
504 return LogicalOperation::AndReverse;
505 case GL_CLEAR:
506 return LogicalOperation::Clear;
507 case GL_COPY:
508 return LogicalOperation::Copy;
509 case GL_COPY_INVERTED:
510 return LogicalOperation::CopyInverted;
511 case GL_EQUIV:
512 return LogicalOperation::Equiv;
513 case GL_INVERT:
514 return LogicalOperation::Invert;
515 case GL_NAND:
516 return LogicalOperation::Nand;
517 case GL_NOOP:
518 return LogicalOperation::Noop;
519 case GL_NOR:
520 return LogicalOperation::Nor;
521 case GL_OR:
522 return LogicalOperation::Or;
523 case GL_OR_INVERTED:
524 return LogicalOperation::OrInverted;
525 case GL_OR_REVERSE:
526 return LogicalOperation::OrReverse;
527 case GL_SET:
528 return LogicalOperation::Set;
529 case GL_XOR:
530 return LogicalOperation::Xor;
531 default:
532 return LogicalOperation::InvalidEnum;
533 }
534}
535
536GLenum ToGLenum(LogicalOperation from)
537{
538 switch (from)
539 {
540 case LogicalOperation::And:
541 return GL_AND;
542 case LogicalOperation::AndInverted:
543 return GL_AND_INVERTED;
544 case LogicalOperation::AndReverse:
545 return GL_AND_REVERSE;
546 case LogicalOperation::Clear:
547 return GL_CLEAR;
548 case LogicalOperation::Copy:
549 return GL_COPY;
550 case LogicalOperation::CopyInverted:
551 return GL_COPY_INVERTED;
552 case LogicalOperation::Equiv:
553 return GL_EQUIV;
554 case LogicalOperation::Invert:
555 return GL_INVERT;
556 case LogicalOperation::Nand:
557 return GL_NAND;
558 case LogicalOperation::Noop:
559 return GL_NOOP;
560 case LogicalOperation::Nor:
561 return GL_NOR;
562 case LogicalOperation::Or:
563 return GL_OR;
564 case LogicalOperation::OrInverted:
565 return GL_OR_INVERTED;
566 case LogicalOperation::OrReverse:
567 return GL_OR_REVERSE;
568 case LogicalOperation::Set:
569 return GL_SET;
570 case LogicalOperation::Xor:
571 return GL_XOR;
572 default:
573 UNREACHABLE();
574 return 0;
575 }
576}
577
578template <>
579MaterialParameter FromGLenum<MaterialParameter>(GLenum from)
580{
581 switch (from)
582 {
583 case GL_AMBIENT:
584 return MaterialParameter::Ambient;
585 case GL_AMBIENT_AND_DIFFUSE:
586 return MaterialParameter::AmbientAndDiffuse;
587 case GL_DIFFUSE:
588 return MaterialParameter::Diffuse;
589 case GL_EMISSION:
590 return MaterialParameter::Emission;
591 case GL_SHININESS:
592 return MaterialParameter::Shininess;
593 case GL_SPECULAR:
594 return MaterialParameter::Specular;
595 default:
596 return MaterialParameter::InvalidEnum;
597 }
598}
599
600GLenum ToGLenum(MaterialParameter from)
601{
602 switch (from)
603 {
604 case MaterialParameter::Ambient:
605 return GL_AMBIENT;
606 case MaterialParameter::AmbientAndDiffuse:
607 return GL_AMBIENT_AND_DIFFUSE;
608 case MaterialParameter::Diffuse:
609 return GL_DIFFUSE;
610 case MaterialParameter::Emission:
611 return GL_EMISSION;
612 case MaterialParameter::Shininess:
613 return GL_SHININESS;
614 case MaterialParameter::Specular:
615 return GL_SPECULAR;
616 default:
617 UNREACHABLE();
618 return 0;
619 }
620}
621
622template <>
623MatrixType FromGLenum<MatrixType>(GLenum from)
624{
625 switch (from)
626 {
627 case GL_MODELVIEW:
628 return MatrixType::Modelview;
629 case GL_PROJECTION:
630 return MatrixType::Projection;
631 case GL_TEXTURE:
632 return MatrixType::Texture;
633 default:
634 return MatrixType::InvalidEnum;
635 }
636}
637
638GLenum ToGLenum(MatrixType from)
639{
640 switch (from)
641 {
642 case MatrixType::Modelview:
643 return GL_MODELVIEW;
644 case MatrixType::Projection:
645 return GL_PROJECTION;
646 case MatrixType::Texture:
647 return GL_TEXTURE;
648 default:
649 UNREACHABLE();
650 return 0;
651 }
652}
653
654template <>
655PointParameter FromGLenum<PointParameter>(GLenum from)
656{
657 switch (from)
658 {
659 case GL_POINT_SIZE_MIN:
660 return PointParameter::PointSizeMin;
661 case GL_POINT_SIZE_MAX:
662 return PointParameter::PointSizeMax;
663 case GL_POINT_FADE_THRESHOLD_SIZE:
664 return PointParameter::PointFadeThresholdSize;
665 case GL_POINT_DISTANCE_ATTENUATION:
666 return PointParameter::PointDistanceAttenuation;
667 default:
668 return PointParameter::InvalidEnum;
669 }
670}
671
672GLenum ToGLenum(PointParameter from)
673{
674 switch (from)
675 {
676 case PointParameter::PointSizeMin:
677 return GL_POINT_SIZE_MIN;
678 case PointParameter::PointSizeMax:
679 return GL_POINT_SIZE_MAX;
680 case PointParameter::PointFadeThresholdSize:
681 return GL_POINT_FADE_THRESHOLD_SIZE;
682 case PointParameter::PointDistanceAttenuation:
683 return GL_POINT_DISTANCE_ATTENUATION;
684 default:
685 UNREACHABLE();
686 return 0;
687 }
688}
689
690template <>
691ProvokingVertex FromGLenum<ProvokingVertex>(GLenum from)
692{
693 switch (from)
694 {
695 case GL_FIRST_VERTEX_CONVENTION:
696 return ProvokingVertex::FirstVertexConvention;
697 case GL_LAST_VERTEX_CONVENTION:
698 return ProvokingVertex::LastVertexConvention;
699 default:
700 return ProvokingVertex::InvalidEnum;
701 }
702}
703
704GLenum ToGLenum(ProvokingVertex from)
705{
706 switch (from)
707 {
708 case ProvokingVertex::FirstVertexConvention:
709 return GL_FIRST_VERTEX_CONVENTION;
710 case ProvokingVertex::LastVertexConvention:
711 return GL_LAST_VERTEX_CONVENTION;
712 default:
713 UNREACHABLE();
714 return 0;
715 }
716}
717
718template <>
719QueryType FromGLenum<QueryType>(GLenum from)
720{
721 switch (from)
722 {
723 case GL_ANY_SAMPLES_PASSED:
724 return QueryType::AnySamples;
725 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
726 return QueryType::AnySamplesConservative;
727 case GL_COMMANDS_COMPLETED_CHROMIUM:
728 return QueryType::CommandsCompleted;
729 case GL_PRIMITIVES_GENERATED_EXT:
730 return QueryType::PrimitivesGenerated;
731 case GL_TIME_ELAPSED_EXT:
732 return QueryType::TimeElapsed;
733 case GL_TIMESTAMP_EXT:
734 return QueryType::Timestamp;
735 case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
736 return QueryType::TransformFeedbackPrimitivesWritten;
737 default:
738 return QueryType::InvalidEnum;
739 }
740}
741
742GLenum ToGLenum(QueryType from)
743{
744 switch (from)
745 {
746 case QueryType::AnySamples:
747 return GL_ANY_SAMPLES_PASSED;
748 case QueryType::AnySamplesConservative:
749 return GL_ANY_SAMPLES_PASSED_CONSERVATIVE;
750 case QueryType::CommandsCompleted:
751 return GL_COMMANDS_COMPLETED_CHROMIUM;
752 case QueryType::PrimitivesGenerated:
753 return GL_PRIMITIVES_GENERATED_EXT;
754 case QueryType::TimeElapsed:
755 return GL_TIME_ELAPSED_EXT;
756 case QueryType::Timestamp:
757 return GL_TIMESTAMP_EXT;
758 case QueryType::TransformFeedbackPrimitivesWritten:
759 return GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN;
760 default:
761 UNREACHABLE();
762 return 0;
763 }
764}
765
766template <>
767ShaderType FromGLenum<ShaderType>(GLenum from)
768{
769 switch (from)
770 {
771 case GL_VERTEX_SHADER:
772 return ShaderType::Vertex;
773 case GL_FRAGMENT_SHADER:
774 return ShaderType::Fragment;
775 case GL_GEOMETRY_SHADER_EXT:
776 return ShaderType::Geometry;
777 case GL_COMPUTE_SHADER:
778 return ShaderType::Compute;
779 default:
780 return ShaderType::InvalidEnum;
781 }
782}
783
784GLenum ToGLenum(ShaderType from)
785{
786 switch (from)
787 {
788 case ShaderType::Vertex:
789 return GL_VERTEX_SHADER;
790 case ShaderType::Fragment:
791 return GL_FRAGMENT_SHADER;
792 case ShaderType::Geometry:
793 return GL_GEOMETRY_SHADER_EXT;
794 case ShaderType::Compute:
795 return GL_COMPUTE_SHADER;
796 default:
797 UNREACHABLE();
798 return 0;
799 }
800}
801
802template <>
803ShadingModel FromGLenum<ShadingModel>(GLenum from)
804{
805 switch (from)
806 {
807 case GL_FLAT:
808 return ShadingModel::Flat;
809 case GL_SMOOTH:
810 return ShadingModel::Smooth;
811 default:
812 return ShadingModel::InvalidEnum;
813 }
814}
815
816GLenum ToGLenum(ShadingModel from)
817{
818 switch (from)
819 {
820 case ShadingModel::Flat:
821 return GL_FLAT;
822 case ShadingModel::Smooth:
823 return GL_SMOOTH;
824 default:
825 UNREACHABLE();
826 return 0;
827 }
828}
829
830template <>
831TextureCombine FromGLenum<TextureCombine>(GLenum from)
832{
833 switch (from)
834 {
835 case GL_ADD:
836 return TextureCombine::Add;
837 case GL_ADD_SIGNED:
838 return TextureCombine::AddSigned;
839 case GL_DOT3_RGB:
840 return TextureCombine::Dot3Rgb;
841 case GL_DOT3_RGBA:
842 return TextureCombine::Dot3Rgba;
843 case GL_INTERPOLATE:
844 return TextureCombine::Interpolate;
845 case GL_MODULATE:
846 return TextureCombine::Modulate;
847 case GL_REPLACE:
848 return TextureCombine::Replace;
849 case GL_SUBTRACT:
850 return TextureCombine::Subtract;
851 default:
852 return TextureCombine::InvalidEnum;
853 }
854}
855
856GLenum ToGLenum(TextureCombine from)
857{
858 switch (from)
859 {
860 case TextureCombine::Add:
861 return GL_ADD;
862 case TextureCombine::AddSigned:
863 return GL_ADD_SIGNED;
864 case TextureCombine::Dot3Rgb:
865 return GL_DOT3_RGB;
866 case TextureCombine::Dot3Rgba:
867 return GL_DOT3_RGBA;
868 case TextureCombine::Interpolate:
869 return GL_INTERPOLATE;
870 case TextureCombine::Modulate:
871 return GL_MODULATE;
872 case TextureCombine::Replace:
873 return GL_REPLACE;
874 case TextureCombine::Subtract:
875 return GL_SUBTRACT;
876 default:
877 UNREACHABLE();
878 return 0;
879 }
880}
881
882template <>
883TextureEnvMode FromGLenum<TextureEnvMode>(GLenum from)
884{
885 switch (from)
886 {
887 case GL_ADD:
888 return TextureEnvMode::Add;
889 case GL_BLEND:
890 return TextureEnvMode::Blend;
891 case GL_COMBINE:
892 return TextureEnvMode::Combine;
893 case GL_DECAL:
894 return TextureEnvMode::Decal;
895 case GL_MODULATE:
896 return TextureEnvMode::Modulate;
897 case GL_REPLACE:
898 return TextureEnvMode::Replace;
899 default:
900 return TextureEnvMode::InvalidEnum;
901 }
902}
903
904GLenum ToGLenum(TextureEnvMode from)
905{
906 switch (from)
907 {
908 case TextureEnvMode::Add:
909 return GL_ADD;
910 case TextureEnvMode::Blend:
911 return GL_BLEND;
912 case TextureEnvMode::Combine:
913 return GL_COMBINE;
914 case TextureEnvMode::Decal:
915 return GL_DECAL;
916 case TextureEnvMode::Modulate:
917 return GL_MODULATE;
918 case TextureEnvMode::Replace:
919 return GL_REPLACE;
920 default:
921 UNREACHABLE();
922 return 0;
923 }
924}
925
926template <>
927TextureEnvParameter FromGLenum<TextureEnvParameter>(GLenum from)
928{
929 switch (from)
930 {
931 case GL_TEXTURE_ENV_MODE:
932 return TextureEnvParameter::Mode;
933 case GL_TEXTURE_ENV_COLOR:
934 return TextureEnvParameter::Color;
935 case GL_COMBINE_RGB:
936 return TextureEnvParameter::CombineRgb;
937 case GL_COMBINE_ALPHA:
938 return TextureEnvParameter::CombineAlpha;
939 case GL_RGB_SCALE:
940 return TextureEnvParameter::RgbScale;
941 case GL_ALPHA_SCALE:
942 return TextureEnvParameter::AlphaScale;
943 case GL_SRC0_RGB:
944 return TextureEnvParameter::Src0Rgb;
945 case GL_SRC1_RGB:
946 return TextureEnvParameter::Src1Rgb;
947 case GL_SRC2_RGB:
948 return TextureEnvParameter::Src2Rgb;
949 case GL_SRC0_ALPHA:
950 return TextureEnvParameter::Src0Alpha;
951 case GL_SRC1_ALPHA:
952 return TextureEnvParameter::Src1Alpha;
953 case GL_SRC2_ALPHA:
954 return TextureEnvParameter::Src2Alpha;
955 case GL_OPERAND0_RGB:
956 return TextureEnvParameter::Op0Rgb;
957 case GL_OPERAND1_RGB:
958 return TextureEnvParameter::Op1Rgb;
959 case GL_OPERAND2_RGB:
960 return TextureEnvParameter::Op2Rgb;
961 case GL_OPERAND0_ALPHA:
962 return TextureEnvParameter::Op0Alpha;
963 case GL_OPERAND1_ALPHA:
964 return TextureEnvParameter::Op1Alpha;
965 case GL_OPERAND2_ALPHA:
966 return TextureEnvParameter::Op2Alpha;
967 case GL_COORD_REPLACE_OES:
968 return TextureEnvParameter::PointCoordReplace;
969 default:
970 return TextureEnvParameter::InvalidEnum;
971 }
972}
973
974GLenum ToGLenum(TextureEnvParameter from)
975{
976 switch (from)
977 {
978 case TextureEnvParameter::Mode:
979 return GL_TEXTURE_ENV_MODE;
980 case TextureEnvParameter::Color:
981 return GL_TEXTURE_ENV_COLOR;
982 case TextureEnvParameter::CombineRgb:
983 return GL_COMBINE_RGB;
984 case TextureEnvParameter::CombineAlpha:
985 return GL_COMBINE_ALPHA;
986 case TextureEnvParameter::RgbScale:
987 return GL_RGB_SCALE;
988 case TextureEnvParameter::AlphaScale:
989 return GL_ALPHA_SCALE;
990 case TextureEnvParameter::Src0Rgb:
991 return GL_SRC0_RGB;
992 case TextureEnvParameter::Src1Rgb:
993 return GL_SRC1_RGB;
994 case TextureEnvParameter::Src2Rgb:
995 return GL_SRC2_RGB;
996 case TextureEnvParameter::Src0Alpha:
997 return GL_SRC0_ALPHA;
998 case TextureEnvParameter::Src1Alpha:
999 return GL_SRC1_ALPHA;
1000 case TextureEnvParameter::Src2Alpha:
1001 return GL_SRC2_ALPHA;
1002 case TextureEnvParameter::Op0Rgb:
1003 return GL_OPERAND0_RGB;
1004 case TextureEnvParameter::Op1Rgb:
1005 return GL_OPERAND1_RGB;
1006 case TextureEnvParameter::Op2Rgb:
1007 return GL_OPERAND2_RGB;
1008 case TextureEnvParameter::Op0Alpha:
1009 return GL_OPERAND0_ALPHA;
1010 case TextureEnvParameter::Op1Alpha:
1011 return GL_OPERAND1_ALPHA;
1012 case TextureEnvParameter::Op2Alpha:
1013 return GL_OPERAND2_ALPHA;
1014 case TextureEnvParameter::PointCoordReplace:
1015 return GL_COORD_REPLACE_OES;
1016 default:
1017 UNREACHABLE();
1018 return 0;
1019 }
1020}
1021
1022template <>
1023TextureEnvTarget FromGLenum<TextureEnvTarget>(GLenum from)
1024{
1025 switch (from)
1026 {
1027 case GL_TEXTURE_ENV:
1028 return TextureEnvTarget::Env;
1029 case GL_POINT_SPRITE_OES:
1030 return TextureEnvTarget::PointSprite;
1031 default:
1032 return TextureEnvTarget::InvalidEnum;
1033 }
1034}
1035
1036GLenum ToGLenum(TextureEnvTarget from)
1037{
1038 switch (from)
1039 {
1040 case TextureEnvTarget::Env:
1041 return GL_TEXTURE_ENV;
1042 case TextureEnvTarget::PointSprite:
1043 return GL_POINT_SPRITE_OES;
1044 default:
1045 UNREACHABLE();
1046 return 0;
1047 }
1048}
1049
1050template <>
1051TextureOp FromGLenum<TextureOp>(GLenum from)
1052{
1053 switch (from)
1054 {
1055 case GL_ONE_MINUS_SRC_ALPHA:
1056 return TextureOp::OneMinusSrcAlpha;
1057 case GL_ONE_MINUS_SRC_COLOR:
1058 return TextureOp::OneMinusSrcColor;
1059 case GL_SRC_ALPHA:
1060 return TextureOp::SrcAlpha;
1061 case GL_SRC_COLOR:
1062 return TextureOp::SrcColor;
1063 default:
1064 return TextureOp::InvalidEnum;
1065 }
1066}
1067
1068GLenum ToGLenum(TextureOp from)
1069{
1070 switch (from)
1071 {
1072 case TextureOp::OneMinusSrcAlpha:
1073 return GL_ONE_MINUS_SRC_ALPHA;
1074 case TextureOp::OneMinusSrcColor:
1075 return GL_ONE_MINUS_SRC_COLOR;
1076 case TextureOp::SrcAlpha:
1077 return GL_SRC_ALPHA;
1078 case TextureOp::SrcColor:
1079 return GL_SRC_COLOR;
1080 default:
1081 UNREACHABLE();
1082 return 0;
1083 }
1084}
1085
1086template <>
1087TextureSrc FromGLenum<TextureSrc>(GLenum from)
1088{
1089 switch (from)
1090 {
1091 case GL_CONSTANT:
1092 return TextureSrc::Constant;
1093 case GL_PREVIOUS:
1094 return TextureSrc::Previous;
1095 case GL_PRIMARY_COLOR:
1096 return TextureSrc::PrimaryColor;
1097 case GL_TEXTURE:
1098 return TextureSrc::Texture;
1099 default:
1100 return TextureSrc::InvalidEnum;
1101 }
1102}
1103
1104GLenum ToGLenum(TextureSrc from)
1105{
1106 switch (from)
1107 {
1108 case TextureSrc::Constant:
1109 return GL_CONSTANT;
1110 case TextureSrc::Previous:
1111 return GL_PREVIOUS;
1112 case TextureSrc::PrimaryColor:
1113 return GL_PRIMARY_COLOR;
1114 case TextureSrc::Texture:
1115 return GL_TEXTURE;
1116 default:
1117 UNREACHABLE();
1118 return 0;
1119 }
1120}
1121
1122template <>
1123TextureTarget FromGLenum<TextureTarget>(GLenum from)
1124{
1125 switch (from)
1126 {
1127 case GL_TEXTURE_2D:
1128 return TextureTarget::_2D;
1129 case GL_TEXTURE_2D_ARRAY:
1130 return TextureTarget::_2DArray;
1131 case GL_TEXTURE_2D_MULTISAMPLE:
1132 return TextureTarget::_2DMultisample;
1133 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES:
1134 return TextureTarget::_2DMultisampleArray;
1135 case GL_TEXTURE_3D:
1136 return TextureTarget::_3D;
1137 case GL_TEXTURE_EXTERNAL_OES:
1138 return TextureTarget::External;
1139 case GL_TEXTURE_RECTANGLE_ANGLE:
1140 return TextureTarget::Rectangle;
1141 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1142 return TextureTarget::CubeMapPositiveX;
1143 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1144 return TextureTarget::CubeMapNegativeX;
1145 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1146 return TextureTarget::CubeMapPositiveY;
1147 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1148 return TextureTarget::CubeMapNegativeY;
1149 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1150 return TextureTarget::CubeMapPositiveZ;
1151 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1152 return TextureTarget::CubeMapNegativeZ;
1153 default:
1154 return TextureTarget::InvalidEnum;
1155 }
1156}
1157
1158GLenum ToGLenum(TextureTarget from)
1159{
1160 switch (from)
1161 {
1162 case TextureTarget::_2D:
1163 return GL_TEXTURE_2D;
1164 case TextureTarget::_2DArray:
1165 return GL_TEXTURE_2D_ARRAY;
1166 case TextureTarget::_2DMultisample:
1167 return GL_TEXTURE_2D_MULTISAMPLE;
1168 case TextureTarget::_2DMultisampleArray:
1169 return GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES;
1170 case TextureTarget::_3D:
1171 return GL_TEXTURE_3D;
1172 case TextureTarget::External:
1173 return GL_TEXTURE_EXTERNAL_OES;
1174 case TextureTarget::Rectangle:
1175 return GL_TEXTURE_RECTANGLE_ANGLE;
1176 case TextureTarget::CubeMapPositiveX:
1177 return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
1178 case TextureTarget::CubeMapNegativeX:
1179 return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
1180 case TextureTarget::CubeMapPositiveY:
1181 return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
1182 case TextureTarget::CubeMapNegativeY:
1183 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
1184 case TextureTarget::CubeMapPositiveZ:
1185 return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
1186 case TextureTarget::CubeMapNegativeZ:
1187 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
1188 default:
1189 UNREACHABLE();
1190 return 0;
1191 }
1192}
1193
1194template <>
1195TextureType FromGLenum<TextureType>(GLenum from)
1196{
1197 switch (from)
1198 {
1199 case GL_TEXTURE_2D:
1200 return TextureType::_2D;
1201 case GL_TEXTURE_2D_ARRAY:
1202 return TextureType::_2DArray;
1203 case GL_TEXTURE_2D_MULTISAMPLE:
1204 return TextureType::_2DMultisample;
1205 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES:
1206 return TextureType::_2DMultisampleArray;
1207 case GL_TEXTURE_3D:
1208 return TextureType::_3D;
1209 case GL_TEXTURE_EXTERNAL_OES:
1210 return TextureType::External;
1211 case GL_TEXTURE_RECTANGLE_ANGLE:
1212 return TextureType::Rectangle;
1213 case GL_TEXTURE_CUBE_MAP:
1214 return TextureType::CubeMap;
1215 default:
1216 return TextureType::InvalidEnum;
1217 }
1218}
1219
1220GLenum ToGLenum(TextureType from)
1221{
1222 switch (from)
1223 {
1224 case TextureType::_2D:
1225 return GL_TEXTURE_2D;
1226 case TextureType::_2DArray:
1227 return GL_TEXTURE_2D_ARRAY;
1228 case TextureType::_2DMultisample:
1229 return GL_TEXTURE_2D_MULTISAMPLE;
1230 case TextureType::_2DMultisampleArray:
1231 return GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES;
1232 case TextureType::_3D:
1233 return GL_TEXTURE_3D;
1234 case TextureType::External:
1235 return GL_TEXTURE_EXTERNAL_OES;
1236 case TextureType::Rectangle:
1237 return GL_TEXTURE_RECTANGLE_ANGLE;
1238 case TextureType::CubeMap:
1239 return GL_TEXTURE_CUBE_MAP;
1240 default:
1241 UNREACHABLE();
1242 return 0;
1243 }
1244}
1245
1246template <>
1247VertexArrayType FromGLenum<VertexArrayType>(GLenum from)
1248{
1249 switch (from)
1250 {
1251 case GL_COLOR_ARRAY:
1252 return VertexArrayType::Color;
1253 case GL_NORMAL_ARRAY:
1254 return VertexArrayType::Normal;
1255 case GL_POINT_SIZE_ARRAY_OES:
1256 return VertexArrayType::PointSize;
1257 case GL_TEXTURE_COORD_ARRAY:
1258 return VertexArrayType::TextureCoord;
1259 case GL_VERTEX_ARRAY:
1260 return VertexArrayType::Vertex;
1261 default:
1262 return VertexArrayType::InvalidEnum;
1263 }
1264}
1265
1266GLenum ToGLenum(VertexArrayType from)
1267{
1268 switch (from)
1269 {
1270 case VertexArrayType::Color:
1271 return GL_COLOR_ARRAY;
1272 case VertexArrayType::Normal:
1273 return GL_NORMAL_ARRAY;
1274 case VertexArrayType::PointSize:
1275 return GL_POINT_SIZE_ARRAY_OES;
1276 case VertexArrayType::TextureCoord:
1277 return GL_TEXTURE_COORD_ARRAY;
1278 case VertexArrayType::Vertex:
1279 return GL_VERTEX_ARRAY;
1280 default:
1281 UNREACHABLE();
1282 return 0;
1283 }
1284}
1285
1286template <>
1287WrapMode FromGLenum<WrapMode>(GLenum from)
1288{
1289 switch (from)
1290 {
1291 case GL_CLAMP_TO_EDGE:
1292 return WrapMode::ClampToEdge;
1293 case GL_CLAMP_TO_BORDER:
1294 return WrapMode::ClampToBorder;
1295 case GL_MIRRORED_REPEAT:
1296 return WrapMode::MirroredRepeat;
1297 case GL_REPEAT:
1298 return WrapMode::Repeat;
1299 default:
1300 return WrapMode::InvalidEnum;
1301 }
1302}
1303
1304GLenum ToGLenum(WrapMode from)
1305{
1306 switch (from)
1307 {
1308 case WrapMode::ClampToEdge:
1309 return GL_CLAMP_TO_EDGE;
1310 case WrapMode::ClampToBorder:
1311 return GL_CLAMP_TO_BORDER;
1312 case WrapMode::MirroredRepeat:
1313 return GL_MIRRORED_REPEAT;
1314 case WrapMode::Repeat:
1315 return GL_REPEAT;
1316 default:
1317 UNREACHABLE();
1318 return 0;
1319 }
1320}
1321
1322} // namespace gl
1323