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
15 namespace gl
16 {
17
18 template <>
FromGLenum(GLenum from)19 AlphaTestFunc 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
ToGLenum(AlphaTestFunc from)44 GLenum 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
operator <<(std::ostream & os,AlphaTestFunc value)70 std::ostream &operator<<(std::ostream &os, AlphaTestFunc value)
71 {
72 switch (value)
73 {
74 case AlphaTestFunc::AlwaysPass:
75 os << "GL_ALWAYS";
76 break;
77 case AlphaTestFunc::Equal:
78 os << "GL_EQUAL";
79 break;
80 case AlphaTestFunc::Gequal:
81 os << "GL_GEQUAL";
82 break;
83 case AlphaTestFunc::Greater:
84 os << "GL_GREATER";
85 break;
86 case AlphaTestFunc::Lequal:
87 os << "GL_LEQUAL";
88 break;
89 case AlphaTestFunc::Less:
90 os << "GL_LESS";
91 break;
92 case AlphaTestFunc::Never:
93 os << "GL_NEVER";
94 break;
95 case AlphaTestFunc::NotEqual:
96 os << "GL_NOTEQUAL";
97 break;
98 default:
99 os << "GL_INVALID_ENUM";
100 break;
101 }
102 return os;
103 }
104
105 template <>
FromGLenum(GLenum from)106 BufferBinding FromGLenum<BufferBinding>(GLenum from)
107 {
108 switch (from)
109 {
110 case GL_ARRAY_BUFFER:
111 return BufferBinding::Array;
112 case GL_ATOMIC_COUNTER_BUFFER:
113 return BufferBinding::AtomicCounter;
114 case GL_COPY_READ_BUFFER:
115 return BufferBinding::CopyRead;
116 case GL_COPY_WRITE_BUFFER:
117 return BufferBinding::CopyWrite;
118 case GL_DISPATCH_INDIRECT_BUFFER:
119 return BufferBinding::DispatchIndirect;
120 case GL_DRAW_INDIRECT_BUFFER:
121 return BufferBinding::DrawIndirect;
122 case GL_ELEMENT_ARRAY_BUFFER:
123 return BufferBinding::ElementArray;
124 case GL_PIXEL_PACK_BUFFER:
125 return BufferBinding::PixelPack;
126 case GL_PIXEL_UNPACK_BUFFER:
127 return BufferBinding::PixelUnpack;
128 case GL_SHADER_STORAGE_BUFFER:
129 return BufferBinding::ShaderStorage;
130 case GL_TRANSFORM_FEEDBACK_BUFFER:
131 return BufferBinding::TransformFeedback;
132 case GL_UNIFORM_BUFFER:
133 return BufferBinding::Uniform;
134 default:
135 return BufferBinding::InvalidEnum;
136 }
137 }
138
ToGLenum(BufferBinding from)139 GLenum ToGLenum(BufferBinding from)
140 {
141 switch (from)
142 {
143 case BufferBinding::Array:
144 return GL_ARRAY_BUFFER;
145 case BufferBinding::AtomicCounter:
146 return GL_ATOMIC_COUNTER_BUFFER;
147 case BufferBinding::CopyRead:
148 return GL_COPY_READ_BUFFER;
149 case BufferBinding::CopyWrite:
150 return GL_COPY_WRITE_BUFFER;
151 case BufferBinding::DispatchIndirect:
152 return GL_DISPATCH_INDIRECT_BUFFER;
153 case BufferBinding::DrawIndirect:
154 return GL_DRAW_INDIRECT_BUFFER;
155 case BufferBinding::ElementArray:
156 return GL_ELEMENT_ARRAY_BUFFER;
157 case BufferBinding::PixelPack:
158 return GL_PIXEL_PACK_BUFFER;
159 case BufferBinding::PixelUnpack:
160 return GL_PIXEL_UNPACK_BUFFER;
161 case BufferBinding::ShaderStorage:
162 return GL_SHADER_STORAGE_BUFFER;
163 case BufferBinding::TransformFeedback:
164 return GL_TRANSFORM_FEEDBACK_BUFFER;
165 case BufferBinding::Uniform:
166 return GL_UNIFORM_BUFFER;
167 default:
168 UNREACHABLE();
169 return 0;
170 }
171 }
172
operator <<(std::ostream & os,BufferBinding value)173 std::ostream &operator<<(std::ostream &os, BufferBinding value)
174 {
175 switch (value)
176 {
177 case BufferBinding::Array:
178 os << "GL_ARRAY_BUFFER";
179 break;
180 case BufferBinding::AtomicCounter:
181 os << "GL_ATOMIC_COUNTER_BUFFER";
182 break;
183 case BufferBinding::CopyRead:
184 os << "GL_COPY_READ_BUFFER";
185 break;
186 case BufferBinding::CopyWrite:
187 os << "GL_COPY_WRITE_BUFFER";
188 break;
189 case BufferBinding::DispatchIndirect:
190 os << "GL_DISPATCH_INDIRECT_BUFFER";
191 break;
192 case BufferBinding::DrawIndirect:
193 os << "GL_DRAW_INDIRECT_BUFFER";
194 break;
195 case BufferBinding::ElementArray:
196 os << "GL_ELEMENT_ARRAY_BUFFER";
197 break;
198 case BufferBinding::PixelPack:
199 os << "GL_PIXEL_PACK_BUFFER";
200 break;
201 case BufferBinding::PixelUnpack:
202 os << "GL_PIXEL_UNPACK_BUFFER";
203 break;
204 case BufferBinding::ShaderStorage:
205 os << "GL_SHADER_STORAGE_BUFFER";
206 break;
207 case BufferBinding::TransformFeedback:
208 os << "GL_TRANSFORM_FEEDBACK_BUFFER";
209 break;
210 case BufferBinding::Uniform:
211 os << "GL_UNIFORM_BUFFER";
212 break;
213 default:
214 os << "GL_INVALID_ENUM";
215 break;
216 }
217 return os;
218 }
219
220 template <>
FromGLenum(GLenum from)221 BufferUsage FromGLenum<BufferUsage>(GLenum from)
222 {
223 switch (from)
224 {
225 case GL_DYNAMIC_COPY:
226 return BufferUsage::DynamicCopy;
227 case GL_DYNAMIC_DRAW:
228 return BufferUsage::DynamicDraw;
229 case GL_DYNAMIC_READ:
230 return BufferUsage::DynamicRead;
231 case GL_STATIC_COPY:
232 return BufferUsage::StaticCopy;
233 case GL_STATIC_DRAW:
234 return BufferUsage::StaticDraw;
235 case GL_STATIC_READ:
236 return BufferUsage::StaticRead;
237 case GL_STREAM_COPY:
238 return BufferUsage::StreamCopy;
239 case GL_STREAM_DRAW:
240 return BufferUsage::StreamDraw;
241 case GL_STREAM_READ:
242 return BufferUsage::StreamRead;
243 default:
244 return BufferUsage::InvalidEnum;
245 }
246 }
247
ToGLenum(BufferUsage from)248 GLenum ToGLenum(BufferUsage from)
249 {
250 switch (from)
251 {
252 case BufferUsage::DynamicCopy:
253 return GL_DYNAMIC_COPY;
254 case BufferUsage::DynamicDraw:
255 return GL_DYNAMIC_DRAW;
256 case BufferUsage::DynamicRead:
257 return GL_DYNAMIC_READ;
258 case BufferUsage::StaticCopy:
259 return GL_STATIC_COPY;
260 case BufferUsage::StaticDraw:
261 return GL_STATIC_DRAW;
262 case BufferUsage::StaticRead:
263 return GL_STATIC_READ;
264 case BufferUsage::StreamCopy:
265 return GL_STREAM_COPY;
266 case BufferUsage::StreamDraw:
267 return GL_STREAM_DRAW;
268 case BufferUsage::StreamRead:
269 return GL_STREAM_READ;
270 default:
271 UNREACHABLE();
272 return 0;
273 }
274 }
275
operator <<(std::ostream & os,BufferUsage value)276 std::ostream &operator<<(std::ostream &os, BufferUsage value)
277 {
278 switch (value)
279 {
280 case BufferUsage::DynamicCopy:
281 os << "GL_DYNAMIC_COPY";
282 break;
283 case BufferUsage::DynamicDraw:
284 os << "GL_DYNAMIC_DRAW";
285 break;
286 case BufferUsage::DynamicRead:
287 os << "GL_DYNAMIC_READ";
288 break;
289 case BufferUsage::StaticCopy:
290 os << "GL_STATIC_COPY";
291 break;
292 case BufferUsage::StaticDraw:
293 os << "GL_STATIC_DRAW";
294 break;
295 case BufferUsage::StaticRead:
296 os << "GL_STATIC_READ";
297 break;
298 case BufferUsage::StreamCopy:
299 os << "GL_STREAM_COPY";
300 break;
301 case BufferUsage::StreamDraw:
302 os << "GL_STREAM_DRAW";
303 break;
304 case BufferUsage::StreamRead:
305 os << "GL_STREAM_READ";
306 break;
307 default:
308 os << "GL_INVALID_ENUM";
309 break;
310 }
311 return os;
312 }
313
314 template <>
FromGLenum(GLenum from)315 ClientVertexArrayType FromGLenum<ClientVertexArrayType>(GLenum from)
316 {
317 switch (from)
318 {
319 case GL_COLOR_ARRAY:
320 return ClientVertexArrayType::Color;
321 case GL_NORMAL_ARRAY:
322 return ClientVertexArrayType::Normal;
323 case GL_POINT_SIZE_ARRAY_OES:
324 return ClientVertexArrayType::PointSize;
325 case GL_TEXTURE_COORD_ARRAY:
326 return ClientVertexArrayType::TextureCoord;
327 case GL_VERTEX_ARRAY:
328 return ClientVertexArrayType::Vertex;
329 default:
330 return ClientVertexArrayType::InvalidEnum;
331 }
332 }
333
ToGLenum(ClientVertexArrayType from)334 GLenum ToGLenum(ClientVertexArrayType from)
335 {
336 switch (from)
337 {
338 case ClientVertexArrayType::Color:
339 return GL_COLOR_ARRAY;
340 case ClientVertexArrayType::Normal:
341 return GL_NORMAL_ARRAY;
342 case ClientVertexArrayType::PointSize:
343 return GL_POINT_SIZE_ARRAY_OES;
344 case ClientVertexArrayType::TextureCoord:
345 return GL_TEXTURE_COORD_ARRAY;
346 case ClientVertexArrayType::Vertex:
347 return GL_VERTEX_ARRAY;
348 default:
349 UNREACHABLE();
350 return 0;
351 }
352 }
353
operator <<(std::ostream & os,ClientVertexArrayType value)354 std::ostream &operator<<(std::ostream &os, ClientVertexArrayType value)
355 {
356 switch (value)
357 {
358 case ClientVertexArrayType::Color:
359 os << "GL_COLOR_ARRAY";
360 break;
361 case ClientVertexArrayType::Normal:
362 os << "GL_NORMAL_ARRAY";
363 break;
364 case ClientVertexArrayType::PointSize:
365 os << "GL_POINT_SIZE_ARRAY_OES";
366 break;
367 case ClientVertexArrayType::TextureCoord:
368 os << "GL_TEXTURE_COORD_ARRAY";
369 break;
370 case ClientVertexArrayType::Vertex:
371 os << "GL_VERTEX_ARRAY";
372 break;
373 default:
374 os << "GL_INVALID_ENUM";
375 break;
376 }
377 return os;
378 }
379
380 template <>
FromGLenum(GLenum from)381 CullFaceMode FromGLenum<CullFaceMode>(GLenum from)
382 {
383 switch (from)
384 {
385 case GL_BACK:
386 return CullFaceMode::Back;
387 case GL_FRONT:
388 return CullFaceMode::Front;
389 case GL_FRONT_AND_BACK:
390 return CullFaceMode::FrontAndBack;
391 default:
392 return CullFaceMode::InvalidEnum;
393 }
394 }
395
ToGLenum(CullFaceMode from)396 GLenum ToGLenum(CullFaceMode from)
397 {
398 switch (from)
399 {
400 case CullFaceMode::Back:
401 return GL_BACK;
402 case CullFaceMode::Front:
403 return GL_FRONT;
404 case CullFaceMode::FrontAndBack:
405 return GL_FRONT_AND_BACK;
406 default:
407 UNREACHABLE();
408 return 0;
409 }
410 }
411
operator <<(std::ostream & os,CullFaceMode value)412 std::ostream &operator<<(std::ostream &os, CullFaceMode value)
413 {
414 switch (value)
415 {
416 case CullFaceMode::Back:
417 os << "GL_BACK";
418 break;
419 case CullFaceMode::Front:
420 os << "GL_FRONT";
421 break;
422 case CullFaceMode::FrontAndBack:
423 os << "GL_FRONT_AND_BACK";
424 break;
425 default:
426 os << "GL_INVALID_ENUM";
427 break;
428 }
429 return os;
430 }
431
432 template <>
FromGLenum(GLenum from)433 FilterMode FromGLenum<FilterMode>(GLenum from)
434 {
435 switch (from)
436 {
437 case GL_NEAREST:
438 return FilterMode::Nearest;
439 case GL_LINEAR:
440 return FilterMode::Linear;
441 case GL_NEAREST_MIPMAP_NEAREST:
442 return FilterMode::NearestMipmapNearest;
443 case GL_NEAREST_MIPMAP_LINEAR:
444 return FilterMode::NearestMipmapLinear;
445 case GL_LINEAR_MIPMAP_LINEAR:
446 return FilterMode::LinearMipmapLinear;
447 default:
448 return FilterMode::InvalidEnum;
449 }
450 }
451
ToGLenum(FilterMode from)452 GLenum ToGLenum(FilterMode from)
453 {
454 switch (from)
455 {
456 case FilterMode::Nearest:
457 return GL_NEAREST;
458 case FilterMode::Linear:
459 return GL_LINEAR;
460 case FilterMode::NearestMipmapNearest:
461 return GL_NEAREST_MIPMAP_NEAREST;
462 case FilterMode::NearestMipmapLinear:
463 return GL_NEAREST_MIPMAP_LINEAR;
464 case FilterMode::LinearMipmapLinear:
465 return GL_LINEAR_MIPMAP_LINEAR;
466 default:
467 UNREACHABLE();
468 return 0;
469 }
470 }
471
operator <<(std::ostream & os,FilterMode value)472 std::ostream &operator<<(std::ostream &os, FilterMode value)
473 {
474 switch (value)
475 {
476 case FilterMode::Nearest:
477 os << "GL_NEAREST";
478 break;
479 case FilterMode::Linear:
480 os << "GL_LINEAR";
481 break;
482 case FilterMode::NearestMipmapNearest:
483 os << "GL_NEAREST_MIPMAP_NEAREST";
484 break;
485 case FilterMode::NearestMipmapLinear:
486 os << "GL_NEAREST_MIPMAP_LINEAR";
487 break;
488 case FilterMode::LinearMipmapLinear:
489 os << "GL_LINEAR_MIPMAP_LINEAR";
490 break;
491 default:
492 os << "GL_INVALID_ENUM";
493 break;
494 }
495 return os;
496 }
497
498 template <>
FromGLenum(GLenum from)499 FogMode FromGLenum<FogMode>(GLenum from)
500 {
501 switch (from)
502 {
503 case GL_EXP:
504 return FogMode::Exp;
505 case GL_EXP2:
506 return FogMode::Exp2;
507 case GL_LINEAR:
508 return FogMode::Linear;
509 default:
510 return FogMode::InvalidEnum;
511 }
512 }
513
ToGLenum(FogMode from)514 GLenum ToGLenum(FogMode from)
515 {
516 switch (from)
517 {
518 case FogMode::Exp:
519 return GL_EXP;
520 case FogMode::Exp2:
521 return GL_EXP2;
522 case FogMode::Linear:
523 return GL_LINEAR;
524 default:
525 UNREACHABLE();
526 return 0;
527 }
528 }
529
operator <<(std::ostream & os,FogMode value)530 std::ostream &operator<<(std::ostream &os, FogMode value)
531 {
532 switch (value)
533 {
534 case FogMode::Exp:
535 os << "GL_EXP";
536 break;
537 case FogMode::Exp2:
538 os << "GL_EXP2";
539 break;
540 case FogMode::Linear:
541 os << "GL_LINEAR";
542 break;
543 default:
544 os << "GL_INVALID_ENUM";
545 break;
546 }
547 return os;
548 }
549
550 template <>
FromGLenum(GLenum from)551 GraphicsResetStatus FromGLenum<GraphicsResetStatus>(GLenum from)
552 {
553 switch (from)
554 {
555 case GL_NO_ERROR:
556 return GraphicsResetStatus::NoError;
557 case GL_GUILTY_CONTEXT_RESET:
558 return GraphicsResetStatus::GuiltyContextReset;
559 case GL_INNOCENT_CONTEXT_RESET:
560 return GraphicsResetStatus::InnocentContextReset;
561 case GL_UNKNOWN_CONTEXT_RESET:
562 return GraphicsResetStatus::UnknownContextReset;
563 default:
564 return GraphicsResetStatus::InvalidEnum;
565 }
566 }
567
ToGLenum(GraphicsResetStatus from)568 GLenum ToGLenum(GraphicsResetStatus from)
569 {
570 switch (from)
571 {
572 case GraphicsResetStatus::NoError:
573 return GL_NO_ERROR;
574 case GraphicsResetStatus::GuiltyContextReset:
575 return GL_GUILTY_CONTEXT_RESET;
576 case GraphicsResetStatus::InnocentContextReset:
577 return GL_INNOCENT_CONTEXT_RESET;
578 case GraphicsResetStatus::UnknownContextReset:
579 return GL_UNKNOWN_CONTEXT_RESET;
580 default:
581 UNREACHABLE();
582 return 0;
583 }
584 }
585
operator <<(std::ostream & os,GraphicsResetStatus value)586 std::ostream &operator<<(std::ostream &os, GraphicsResetStatus value)
587 {
588 switch (value)
589 {
590 case GraphicsResetStatus::NoError:
591 os << "GL_NO_ERROR";
592 break;
593 case GraphicsResetStatus::GuiltyContextReset:
594 os << "GL_GUILTY_CONTEXT_RESET";
595 break;
596 case GraphicsResetStatus::InnocentContextReset:
597 os << "GL_INNOCENT_CONTEXT_RESET";
598 break;
599 case GraphicsResetStatus::UnknownContextReset:
600 os << "GL_UNKNOWN_CONTEXT_RESET";
601 break;
602 default:
603 os << "GL_INVALID_ENUM";
604 break;
605 }
606 return os;
607 }
608
609 template <>
FromGLenum(GLenum from)610 HandleType FromGLenum<HandleType>(GLenum from)
611 {
612 switch (from)
613 {
614 case GL_HANDLE_TYPE_OPAQUE_FD_EXT:
615 return HandleType::OpaqueFd;
616 default:
617 return HandleType::InvalidEnum;
618 }
619 }
620
ToGLenum(HandleType from)621 GLenum ToGLenum(HandleType from)
622 {
623 switch (from)
624 {
625 case HandleType::OpaqueFd:
626 return GL_HANDLE_TYPE_OPAQUE_FD_EXT;
627 default:
628 UNREACHABLE();
629 return 0;
630 }
631 }
632
operator <<(std::ostream & os,HandleType value)633 std::ostream &operator<<(std::ostream &os, HandleType value)
634 {
635 switch (value)
636 {
637 case HandleType::OpaqueFd:
638 os << "GL_HANDLE_TYPE_OPAQUE_FD_EXT";
639 break;
640 default:
641 os << "GL_INVALID_ENUM";
642 break;
643 }
644 return os;
645 }
646
647 template <>
FromGLenum(GLenum from)648 HintSetting FromGLenum<HintSetting>(GLenum from)
649 {
650 switch (from)
651 {
652 case GL_DONT_CARE:
653 return HintSetting::DontCare;
654 case GL_FASTEST:
655 return HintSetting::Fastest;
656 case GL_NICEST:
657 return HintSetting::Nicest;
658 default:
659 return HintSetting::InvalidEnum;
660 }
661 }
662
ToGLenum(HintSetting from)663 GLenum ToGLenum(HintSetting from)
664 {
665 switch (from)
666 {
667 case HintSetting::DontCare:
668 return GL_DONT_CARE;
669 case HintSetting::Fastest:
670 return GL_FASTEST;
671 case HintSetting::Nicest:
672 return GL_NICEST;
673 default:
674 UNREACHABLE();
675 return 0;
676 }
677 }
678
operator <<(std::ostream & os,HintSetting value)679 std::ostream &operator<<(std::ostream &os, HintSetting value)
680 {
681 switch (value)
682 {
683 case HintSetting::DontCare:
684 os << "GL_DONT_CARE";
685 break;
686 case HintSetting::Fastest:
687 os << "GL_FASTEST";
688 break;
689 case HintSetting::Nicest:
690 os << "GL_NICEST";
691 break;
692 default:
693 os << "GL_INVALID_ENUM";
694 break;
695 }
696 return os;
697 }
698
699 template <>
FromGLenum(GLenum from)700 ImageLayout FromGLenum<ImageLayout>(GLenum from)
701 {
702 switch (from)
703 {
704 case GL_NONE:
705 return ImageLayout::Undefined;
706 case GL_LAYOUT_GENERAL_EXT:
707 return ImageLayout::General;
708 case GL_LAYOUT_COLOR_ATTACHMENT_EXT:
709 return ImageLayout::ColorAttachment;
710 case GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT:
711 return ImageLayout::DepthStencilAttachment;
712 case GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT:
713 return ImageLayout::DepthStencilReadOnlyAttachment;
714 case GL_LAYOUT_SHADER_READ_ONLY_EXT:
715 return ImageLayout::ShaderReadOnly;
716 case GL_LAYOUT_TRANSFER_SRC_EXT:
717 return ImageLayout::TransferSrc;
718 case GL_LAYOUT_TRANSFER_DST_EXT:
719 return ImageLayout::TransferDst;
720 case GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT:
721 return ImageLayout::DepthReadOnlyStencilAttachment;
722 case GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT:
723 return ImageLayout::DepthAttachmentStencilReadOnly;
724 default:
725 return ImageLayout::InvalidEnum;
726 }
727 }
728
ToGLenum(ImageLayout from)729 GLenum ToGLenum(ImageLayout from)
730 {
731 switch (from)
732 {
733 case ImageLayout::Undefined:
734 return GL_NONE;
735 case ImageLayout::General:
736 return GL_LAYOUT_GENERAL_EXT;
737 case ImageLayout::ColorAttachment:
738 return GL_LAYOUT_COLOR_ATTACHMENT_EXT;
739 case ImageLayout::DepthStencilAttachment:
740 return GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT;
741 case ImageLayout::DepthStencilReadOnlyAttachment:
742 return GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT;
743 case ImageLayout::ShaderReadOnly:
744 return GL_LAYOUT_SHADER_READ_ONLY_EXT;
745 case ImageLayout::TransferSrc:
746 return GL_LAYOUT_TRANSFER_SRC_EXT;
747 case ImageLayout::TransferDst:
748 return GL_LAYOUT_TRANSFER_DST_EXT;
749 case ImageLayout::DepthReadOnlyStencilAttachment:
750 return GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT;
751 case ImageLayout::DepthAttachmentStencilReadOnly:
752 return GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT;
753 default:
754 UNREACHABLE();
755 return 0;
756 }
757 }
758
operator <<(std::ostream & os,ImageLayout value)759 std::ostream &operator<<(std::ostream &os, ImageLayout value)
760 {
761 switch (value)
762 {
763 case ImageLayout::Undefined:
764 os << "GL_NONE";
765 break;
766 case ImageLayout::General:
767 os << "GL_LAYOUT_GENERAL_EXT";
768 break;
769 case ImageLayout::ColorAttachment:
770 os << "GL_LAYOUT_COLOR_ATTACHMENT_EXT";
771 break;
772 case ImageLayout::DepthStencilAttachment:
773 os << "GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT";
774 break;
775 case ImageLayout::DepthStencilReadOnlyAttachment:
776 os << "GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT";
777 break;
778 case ImageLayout::ShaderReadOnly:
779 os << "GL_LAYOUT_SHADER_READ_ONLY_EXT";
780 break;
781 case ImageLayout::TransferSrc:
782 os << "GL_LAYOUT_TRANSFER_SRC_EXT";
783 break;
784 case ImageLayout::TransferDst:
785 os << "GL_LAYOUT_TRANSFER_DST_EXT";
786 break;
787 case ImageLayout::DepthReadOnlyStencilAttachment:
788 os << "GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT";
789 break;
790 case ImageLayout::DepthAttachmentStencilReadOnly:
791 os << "GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT";
792 break;
793 default:
794 os << "GL_INVALID_ENUM";
795 break;
796 }
797 return os;
798 }
799
800 template <>
FromGLenum(GLenum from)801 LightParameter FromGLenum<LightParameter>(GLenum from)
802 {
803 switch (from)
804 {
805 case GL_AMBIENT:
806 return LightParameter::Ambient;
807 case GL_AMBIENT_AND_DIFFUSE:
808 return LightParameter::AmbientAndDiffuse;
809 case GL_CONSTANT_ATTENUATION:
810 return LightParameter::ConstantAttenuation;
811 case GL_DIFFUSE:
812 return LightParameter::Diffuse;
813 case GL_LINEAR_ATTENUATION:
814 return LightParameter::LinearAttenuation;
815 case GL_POSITION:
816 return LightParameter::Position;
817 case GL_QUADRATIC_ATTENUATION:
818 return LightParameter::QuadraticAttenuation;
819 case GL_SPECULAR:
820 return LightParameter::Specular;
821 case GL_SPOT_CUTOFF:
822 return LightParameter::SpotCutoff;
823 case GL_SPOT_DIRECTION:
824 return LightParameter::SpotDirection;
825 case GL_SPOT_EXPONENT:
826 return LightParameter::SpotExponent;
827 default:
828 return LightParameter::InvalidEnum;
829 }
830 }
831
ToGLenum(LightParameter from)832 GLenum ToGLenum(LightParameter from)
833 {
834 switch (from)
835 {
836 case LightParameter::Ambient:
837 return GL_AMBIENT;
838 case LightParameter::AmbientAndDiffuse:
839 return GL_AMBIENT_AND_DIFFUSE;
840 case LightParameter::ConstantAttenuation:
841 return GL_CONSTANT_ATTENUATION;
842 case LightParameter::Diffuse:
843 return GL_DIFFUSE;
844 case LightParameter::LinearAttenuation:
845 return GL_LINEAR_ATTENUATION;
846 case LightParameter::Position:
847 return GL_POSITION;
848 case LightParameter::QuadraticAttenuation:
849 return GL_QUADRATIC_ATTENUATION;
850 case LightParameter::Specular:
851 return GL_SPECULAR;
852 case LightParameter::SpotCutoff:
853 return GL_SPOT_CUTOFF;
854 case LightParameter::SpotDirection:
855 return GL_SPOT_DIRECTION;
856 case LightParameter::SpotExponent:
857 return GL_SPOT_EXPONENT;
858 default:
859 UNREACHABLE();
860 return 0;
861 }
862 }
863
operator <<(std::ostream & os,LightParameter value)864 std::ostream &operator<<(std::ostream &os, LightParameter value)
865 {
866 switch (value)
867 {
868 case LightParameter::Ambient:
869 os << "GL_AMBIENT";
870 break;
871 case LightParameter::AmbientAndDiffuse:
872 os << "GL_AMBIENT_AND_DIFFUSE";
873 break;
874 case LightParameter::ConstantAttenuation:
875 os << "GL_CONSTANT_ATTENUATION";
876 break;
877 case LightParameter::Diffuse:
878 os << "GL_DIFFUSE";
879 break;
880 case LightParameter::LinearAttenuation:
881 os << "GL_LINEAR_ATTENUATION";
882 break;
883 case LightParameter::Position:
884 os << "GL_POSITION";
885 break;
886 case LightParameter::QuadraticAttenuation:
887 os << "GL_QUADRATIC_ATTENUATION";
888 break;
889 case LightParameter::Specular:
890 os << "GL_SPECULAR";
891 break;
892 case LightParameter::SpotCutoff:
893 os << "GL_SPOT_CUTOFF";
894 break;
895 case LightParameter::SpotDirection:
896 os << "GL_SPOT_DIRECTION";
897 break;
898 case LightParameter::SpotExponent:
899 os << "GL_SPOT_EXPONENT";
900 break;
901 default:
902 os << "GL_INVALID_ENUM";
903 break;
904 }
905 return os;
906 }
907
908 template <>
FromGLenum(GLenum from)909 LogicalOperation FromGLenum<LogicalOperation>(GLenum from)
910 {
911 switch (from)
912 {
913 case GL_AND:
914 return LogicalOperation::And;
915 case GL_AND_INVERTED:
916 return LogicalOperation::AndInverted;
917 case GL_AND_REVERSE:
918 return LogicalOperation::AndReverse;
919 case GL_CLEAR:
920 return LogicalOperation::Clear;
921 case GL_COPY:
922 return LogicalOperation::Copy;
923 case GL_COPY_INVERTED:
924 return LogicalOperation::CopyInverted;
925 case GL_EQUIV:
926 return LogicalOperation::Equiv;
927 case GL_INVERT:
928 return LogicalOperation::Invert;
929 case GL_NAND:
930 return LogicalOperation::Nand;
931 case GL_NOOP:
932 return LogicalOperation::Noop;
933 case GL_NOR:
934 return LogicalOperation::Nor;
935 case GL_OR:
936 return LogicalOperation::Or;
937 case GL_OR_INVERTED:
938 return LogicalOperation::OrInverted;
939 case GL_OR_REVERSE:
940 return LogicalOperation::OrReverse;
941 case GL_SET:
942 return LogicalOperation::Set;
943 case GL_XOR:
944 return LogicalOperation::Xor;
945 default:
946 return LogicalOperation::InvalidEnum;
947 }
948 }
949
ToGLenum(LogicalOperation from)950 GLenum ToGLenum(LogicalOperation from)
951 {
952 switch (from)
953 {
954 case LogicalOperation::And:
955 return GL_AND;
956 case LogicalOperation::AndInverted:
957 return GL_AND_INVERTED;
958 case LogicalOperation::AndReverse:
959 return GL_AND_REVERSE;
960 case LogicalOperation::Clear:
961 return GL_CLEAR;
962 case LogicalOperation::Copy:
963 return GL_COPY;
964 case LogicalOperation::CopyInverted:
965 return GL_COPY_INVERTED;
966 case LogicalOperation::Equiv:
967 return GL_EQUIV;
968 case LogicalOperation::Invert:
969 return GL_INVERT;
970 case LogicalOperation::Nand:
971 return GL_NAND;
972 case LogicalOperation::Noop:
973 return GL_NOOP;
974 case LogicalOperation::Nor:
975 return GL_NOR;
976 case LogicalOperation::Or:
977 return GL_OR;
978 case LogicalOperation::OrInverted:
979 return GL_OR_INVERTED;
980 case LogicalOperation::OrReverse:
981 return GL_OR_REVERSE;
982 case LogicalOperation::Set:
983 return GL_SET;
984 case LogicalOperation::Xor:
985 return GL_XOR;
986 default:
987 UNREACHABLE();
988 return 0;
989 }
990 }
991
operator <<(std::ostream & os,LogicalOperation value)992 std::ostream &operator<<(std::ostream &os, LogicalOperation value)
993 {
994 switch (value)
995 {
996 case LogicalOperation::And:
997 os << "GL_AND";
998 break;
999 case LogicalOperation::AndInverted:
1000 os << "GL_AND_INVERTED";
1001 break;
1002 case LogicalOperation::AndReverse:
1003 os << "GL_AND_REVERSE";
1004 break;
1005 case LogicalOperation::Clear:
1006 os << "GL_CLEAR";
1007 break;
1008 case LogicalOperation::Copy:
1009 os << "GL_COPY";
1010 break;
1011 case LogicalOperation::CopyInverted:
1012 os << "GL_COPY_INVERTED";
1013 break;
1014 case LogicalOperation::Equiv:
1015 os << "GL_EQUIV";
1016 break;
1017 case LogicalOperation::Invert:
1018 os << "GL_INVERT";
1019 break;
1020 case LogicalOperation::Nand:
1021 os << "GL_NAND";
1022 break;
1023 case LogicalOperation::Noop:
1024 os << "GL_NOOP";
1025 break;
1026 case LogicalOperation::Nor:
1027 os << "GL_NOR";
1028 break;
1029 case LogicalOperation::Or:
1030 os << "GL_OR";
1031 break;
1032 case LogicalOperation::OrInverted:
1033 os << "GL_OR_INVERTED";
1034 break;
1035 case LogicalOperation::OrReverse:
1036 os << "GL_OR_REVERSE";
1037 break;
1038 case LogicalOperation::Set:
1039 os << "GL_SET";
1040 break;
1041 case LogicalOperation::Xor:
1042 os << "GL_XOR";
1043 break;
1044 default:
1045 os << "GL_INVALID_ENUM";
1046 break;
1047 }
1048 return os;
1049 }
1050
1051 template <>
FromGLenum(GLenum from)1052 MaterialParameter FromGLenum<MaterialParameter>(GLenum from)
1053 {
1054 switch (from)
1055 {
1056 case GL_AMBIENT:
1057 return MaterialParameter::Ambient;
1058 case GL_AMBIENT_AND_DIFFUSE:
1059 return MaterialParameter::AmbientAndDiffuse;
1060 case GL_DIFFUSE:
1061 return MaterialParameter::Diffuse;
1062 case GL_EMISSION:
1063 return MaterialParameter::Emission;
1064 case GL_SHININESS:
1065 return MaterialParameter::Shininess;
1066 case GL_SPECULAR:
1067 return MaterialParameter::Specular;
1068 default:
1069 return MaterialParameter::InvalidEnum;
1070 }
1071 }
1072
ToGLenum(MaterialParameter from)1073 GLenum ToGLenum(MaterialParameter from)
1074 {
1075 switch (from)
1076 {
1077 case MaterialParameter::Ambient:
1078 return GL_AMBIENT;
1079 case MaterialParameter::AmbientAndDiffuse:
1080 return GL_AMBIENT_AND_DIFFUSE;
1081 case MaterialParameter::Diffuse:
1082 return GL_DIFFUSE;
1083 case MaterialParameter::Emission:
1084 return GL_EMISSION;
1085 case MaterialParameter::Shininess:
1086 return GL_SHININESS;
1087 case MaterialParameter::Specular:
1088 return GL_SPECULAR;
1089 default:
1090 UNREACHABLE();
1091 return 0;
1092 }
1093 }
1094
operator <<(std::ostream & os,MaterialParameter value)1095 std::ostream &operator<<(std::ostream &os, MaterialParameter value)
1096 {
1097 switch (value)
1098 {
1099 case MaterialParameter::Ambient:
1100 os << "GL_AMBIENT";
1101 break;
1102 case MaterialParameter::AmbientAndDiffuse:
1103 os << "GL_AMBIENT_AND_DIFFUSE";
1104 break;
1105 case MaterialParameter::Diffuse:
1106 os << "GL_DIFFUSE";
1107 break;
1108 case MaterialParameter::Emission:
1109 os << "GL_EMISSION";
1110 break;
1111 case MaterialParameter::Shininess:
1112 os << "GL_SHININESS";
1113 break;
1114 case MaterialParameter::Specular:
1115 os << "GL_SPECULAR";
1116 break;
1117 default:
1118 os << "GL_INVALID_ENUM";
1119 break;
1120 }
1121 return os;
1122 }
1123
1124 template <>
FromGLenum(GLenum from)1125 MatrixType FromGLenum<MatrixType>(GLenum from)
1126 {
1127 switch (from)
1128 {
1129 case GL_MODELVIEW:
1130 return MatrixType::Modelview;
1131 case GL_PROJECTION:
1132 return MatrixType::Projection;
1133 case GL_TEXTURE:
1134 return MatrixType::Texture;
1135 default:
1136 return MatrixType::InvalidEnum;
1137 }
1138 }
1139
ToGLenum(MatrixType from)1140 GLenum ToGLenum(MatrixType from)
1141 {
1142 switch (from)
1143 {
1144 case MatrixType::Modelview:
1145 return GL_MODELVIEW;
1146 case MatrixType::Projection:
1147 return GL_PROJECTION;
1148 case MatrixType::Texture:
1149 return GL_TEXTURE;
1150 default:
1151 UNREACHABLE();
1152 return 0;
1153 }
1154 }
1155
operator <<(std::ostream & os,MatrixType value)1156 std::ostream &operator<<(std::ostream &os, MatrixType value)
1157 {
1158 switch (value)
1159 {
1160 case MatrixType::Modelview:
1161 os << "GL_MODELVIEW";
1162 break;
1163 case MatrixType::Projection:
1164 os << "GL_PROJECTION";
1165 break;
1166 case MatrixType::Texture:
1167 os << "GL_TEXTURE";
1168 break;
1169 default:
1170 os << "GL_INVALID_ENUM";
1171 break;
1172 }
1173 return os;
1174 }
1175
1176 template <>
FromGLenum(GLenum from)1177 PointParameter FromGLenum<PointParameter>(GLenum from)
1178 {
1179 switch (from)
1180 {
1181 case GL_POINT_SIZE_MIN:
1182 return PointParameter::PointSizeMin;
1183 case GL_POINT_SIZE_MAX:
1184 return PointParameter::PointSizeMax;
1185 case GL_POINT_FADE_THRESHOLD_SIZE:
1186 return PointParameter::PointFadeThresholdSize;
1187 case GL_POINT_DISTANCE_ATTENUATION:
1188 return PointParameter::PointDistanceAttenuation;
1189 default:
1190 return PointParameter::InvalidEnum;
1191 }
1192 }
1193
ToGLenum(PointParameter from)1194 GLenum ToGLenum(PointParameter from)
1195 {
1196 switch (from)
1197 {
1198 case PointParameter::PointSizeMin:
1199 return GL_POINT_SIZE_MIN;
1200 case PointParameter::PointSizeMax:
1201 return GL_POINT_SIZE_MAX;
1202 case PointParameter::PointFadeThresholdSize:
1203 return GL_POINT_FADE_THRESHOLD_SIZE;
1204 case PointParameter::PointDistanceAttenuation:
1205 return GL_POINT_DISTANCE_ATTENUATION;
1206 default:
1207 UNREACHABLE();
1208 return 0;
1209 }
1210 }
1211
operator <<(std::ostream & os,PointParameter value)1212 std::ostream &operator<<(std::ostream &os, PointParameter value)
1213 {
1214 switch (value)
1215 {
1216 case PointParameter::PointSizeMin:
1217 os << "GL_POINT_SIZE_MIN";
1218 break;
1219 case PointParameter::PointSizeMax:
1220 os << "GL_POINT_SIZE_MAX";
1221 break;
1222 case PointParameter::PointFadeThresholdSize:
1223 os << "GL_POINT_FADE_THRESHOLD_SIZE";
1224 break;
1225 case PointParameter::PointDistanceAttenuation:
1226 os << "GL_POINT_DISTANCE_ATTENUATION";
1227 break;
1228 default:
1229 os << "GL_INVALID_ENUM";
1230 break;
1231 }
1232 return os;
1233 }
1234
1235 template <>
FromGLenum(GLenum from)1236 ProvokingVertexConvention FromGLenum<ProvokingVertexConvention>(GLenum from)
1237 {
1238 switch (from)
1239 {
1240 case GL_FIRST_VERTEX_CONVENTION:
1241 return ProvokingVertexConvention::FirstVertexConvention;
1242 case GL_LAST_VERTEX_CONVENTION:
1243 return ProvokingVertexConvention::LastVertexConvention;
1244 default:
1245 return ProvokingVertexConvention::InvalidEnum;
1246 }
1247 }
1248
ToGLenum(ProvokingVertexConvention from)1249 GLenum ToGLenum(ProvokingVertexConvention from)
1250 {
1251 switch (from)
1252 {
1253 case ProvokingVertexConvention::FirstVertexConvention:
1254 return GL_FIRST_VERTEX_CONVENTION;
1255 case ProvokingVertexConvention::LastVertexConvention:
1256 return GL_LAST_VERTEX_CONVENTION;
1257 default:
1258 UNREACHABLE();
1259 return 0;
1260 }
1261 }
1262
operator <<(std::ostream & os,ProvokingVertexConvention value)1263 std::ostream &operator<<(std::ostream &os, ProvokingVertexConvention value)
1264 {
1265 switch (value)
1266 {
1267 case ProvokingVertexConvention::FirstVertexConvention:
1268 os << "GL_FIRST_VERTEX_CONVENTION";
1269 break;
1270 case ProvokingVertexConvention::LastVertexConvention:
1271 os << "GL_LAST_VERTEX_CONVENTION";
1272 break;
1273 default:
1274 os << "GL_INVALID_ENUM";
1275 break;
1276 }
1277 return os;
1278 }
1279
1280 template <>
FromGLenum(GLenum from)1281 QueryType FromGLenum<QueryType>(GLenum from)
1282 {
1283 switch (from)
1284 {
1285 case GL_ANY_SAMPLES_PASSED:
1286 return QueryType::AnySamples;
1287 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
1288 return QueryType::AnySamplesConservative;
1289 case GL_COMMANDS_COMPLETED_CHROMIUM:
1290 return QueryType::CommandsCompleted;
1291 case GL_PRIMITIVES_GENERATED_EXT:
1292 return QueryType::PrimitivesGenerated;
1293 case GL_TIME_ELAPSED_EXT:
1294 return QueryType::TimeElapsed;
1295 case GL_TIMESTAMP_EXT:
1296 return QueryType::Timestamp;
1297 case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
1298 return QueryType::TransformFeedbackPrimitivesWritten;
1299 default:
1300 return QueryType::InvalidEnum;
1301 }
1302 }
1303
ToGLenum(QueryType from)1304 GLenum ToGLenum(QueryType from)
1305 {
1306 switch (from)
1307 {
1308 case QueryType::AnySamples:
1309 return GL_ANY_SAMPLES_PASSED;
1310 case QueryType::AnySamplesConservative:
1311 return GL_ANY_SAMPLES_PASSED_CONSERVATIVE;
1312 case QueryType::CommandsCompleted:
1313 return GL_COMMANDS_COMPLETED_CHROMIUM;
1314 case QueryType::PrimitivesGenerated:
1315 return GL_PRIMITIVES_GENERATED_EXT;
1316 case QueryType::TimeElapsed:
1317 return GL_TIME_ELAPSED_EXT;
1318 case QueryType::Timestamp:
1319 return GL_TIMESTAMP_EXT;
1320 case QueryType::TransformFeedbackPrimitivesWritten:
1321 return GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN;
1322 default:
1323 UNREACHABLE();
1324 return 0;
1325 }
1326 }
1327
operator <<(std::ostream & os,QueryType value)1328 std::ostream &operator<<(std::ostream &os, QueryType value)
1329 {
1330 switch (value)
1331 {
1332 case QueryType::AnySamples:
1333 os << "GL_ANY_SAMPLES_PASSED";
1334 break;
1335 case QueryType::AnySamplesConservative:
1336 os << "GL_ANY_SAMPLES_PASSED_CONSERVATIVE";
1337 break;
1338 case QueryType::CommandsCompleted:
1339 os << "GL_COMMANDS_COMPLETED_CHROMIUM";
1340 break;
1341 case QueryType::PrimitivesGenerated:
1342 os << "GL_PRIMITIVES_GENERATED_EXT";
1343 break;
1344 case QueryType::TimeElapsed:
1345 os << "GL_TIME_ELAPSED_EXT";
1346 break;
1347 case QueryType::Timestamp:
1348 os << "GL_TIMESTAMP_EXT";
1349 break;
1350 case QueryType::TransformFeedbackPrimitivesWritten:
1351 os << "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN";
1352 break;
1353 default:
1354 os << "GL_INVALID_ENUM";
1355 break;
1356 }
1357 return os;
1358 }
1359
1360 template <>
FromGLenum(GLenum from)1361 ShaderType FromGLenum<ShaderType>(GLenum from)
1362 {
1363 switch (from)
1364 {
1365 case GL_VERTEX_SHADER:
1366 return ShaderType::Vertex;
1367 case GL_FRAGMENT_SHADER:
1368 return ShaderType::Fragment;
1369 case GL_GEOMETRY_SHADER_EXT:
1370 return ShaderType::Geometry;
1371 case GL_COMPUTE_SHADER:
1372 return ShaderType::Compute;
1373 default:
1374 return ShaderType::InvalidEnum;
1375 }
1376 }
1377
ToGLenum(ShaderType from)1378 GLenum ToGLenum(ShaderType from)
1379 {
1380 switch (from)
1381 {
1382 case ShaderType::Vertex:
1383 return GL_VERTEX_SHADER;
1384 case ShaderType::Fragment:
1385 return GL_FRAGMENT_SHADER;
1386 case ShaderType::Geometry:
1387 return GL_GEOMETRY_SHADER_EXT;
1388 case ShaderType::Compute:
1389 return GL_COMPUTE_SHADER;
1390 default:
1391 UNREACHABLE();
1392 return 0;
1393 }
1394 }
1395
operator <<(std::ostream & os,ShaderType value)1396 std::ostream &operator<<(std::ostream &os, ShaderType value)
1397 {
1398 switch (value)
1399 {
1400 case ShaderType::Vertex:
1401 os << "GL_VERTEX_SHADER";
1402 break;
1403 case ShaderType::Fragment:
1404 os << "GL_FRAGMENT_SHADER";
1405 break;
1406 case ShaderType::Geometry:
1407 os << "GL_GEOMETRY_SHADER_EXT";
1408 break;
1409 case ShaderType::Compute:
1410 os << "GL_COMPUTE_SHADER";
1411 break;
1412 default:
1413 os << "GL_INVALID_ENUM";
1414 break;
1415 }
1416 return os;
1417 }
1418
1419 template <>
FromGLenum(GLenum from)1420 ShadingModel FromGLenum<ShadingModel>(GLenum from)
1421 {
1422 switch (from)
1423 {
1424 case GL_FLAT:
1425 return ShadingModel::Flat;
1426 case GL_SMOOTH:
1427 return ShadingModel::Smooth;
1428 default:
1429 return ShadingModel::InvalidEnum;
1430 }
1431 }
1432
ToGLenum(ShadingModel from)1433 GLenum ToGLenum(ShadingModel from)
1434 {
1435 switch (from)
1436 {
1437 case ShadingModel::Flat:
1438 return GL_FLAT;
1439 case ShadingModel::Smooth:
1440 return GL_SMOOTH;
1441 default:
1442 UNREACHABLE();
1443 return 0;
1444 }
1445 }
1446
operator <<(std::ostream & os,ShadingModel value)1447 std::ostream &operator<<(std::ostream &os, ShadingModel value)
1448 {
1449 switch (value)
1450 {
1451 case ShadingModel::Flat:
1452 os << "GL_FLAT";
1453 break;
1454 case ShadingModel::Smooth:
1455 os << "GL_SMOOTH";
1456 break;
1457 default:
1458 os << "GL_INVALID_ENUM";
1459 break;
1460 }
1461 return os;
1462 }
1463
1464 template <>
FromGLenum(GLenum from)1465 TextureCombine FromGLenum<TextureCombine>(GLenum from)
1466 {
1467 switch (from)
1468 {
1469 case GL_ADD:
1470 return TextureCombine::Add;
1471 case GL_ADD_SIGNED:
1472 return TextureCombine::AddSigned;
1473 case GL_DOT3_RGB:
1474 return TextureCombine::Dot3Rgb;
1475 case GL_DOT3_RGBA:
1476 return TextureCombine::Dot3Rgba;
1477 case GL_INTERPOLATE:
1478 return TextureCombine::Interpolate;
1479 case GL_MODULATE:
1480 return TextureCombine::Modulate;
1481 case GL_REPLACE:
1482 return TextureCombine::Replace;
1483 case GL_SUBTRACT:
1484 return TextureCombine::Subtract;
1485 default:
1486 return TextureCombine::InvalidEnum;
1487 }
1488 }
1489
ToGLenum(TextureCombine from)1490 GLenum ToGLenum(TextureCombine from)
1491 {
1492 switch (from)
1493 {
1494 case TextureCombine::Add:
1495 return GL_ADD;
1496 case TextureCombine::AddSigned:
1497 return GL_ADD_SIGNED;
1498 case TextureCombine::Dot3Rgb:
1499 return GL_DOT3_RGB;
1500 case TextureCombine::Dot3Rgba:
1501 return GL_DOT3_RGBA;
1502 case TextureCombine::Interpolate:
1503 return GL_INTERPOLATE;
1504 case TextureCombine::Modulate:
1505 return GL_MODULATE;
1506 case TextureCombine::Replace:
1507 return GL_REPLACE;
1508 case TextureCombine::Subtract:
1509 return GL_SUBTRACT;
1510 default:
1511 UNREACHABLE();
1512 return 0;
1513 }
1514 }
1515
operator <<(std::ostream & os,TextureCombine value)1516 std::ostream &operator<<(std::ostream &os, TextureCombine value)
1517 {
1518 switch (value)
1519 {
1520 case TextureCombine::Add:
1521 os << "GL_ADD";
1522 break;
1523 case TextureCombine::AddSigned:
1524 os << "GL_ADD_SIGNED";
1525 break;
1526 case TextureCombine::Dot3Rgb:
1527 os << "GL_DOT3_RGB";
1528 break;
1529 case TextureCombine::Dot3Rgba:
1530 os << "GL_DOT3_RGBA";
1531 break;
1532 case TextureCombine::Interpolate:
1533 os << "GL_INTERPOLATE";
1534 break;
1535 case TextureCombine::Modulate:
1536 os << "GL_MODULATE";
1537 break;
1538 case TextureCombine::Replace:
1539 os << "GL_REPLACE";
1540 break;
1541 case TextureCombine::Subtract:
1542 os << "GL_SUBTRACT";
1543 break;
1544 default:
1545 os << "GL_INVALID_ENUM";
1546 break;
1547 }
1548 return os;
1549 }
1550
1551 template <>
FromGLenum(GLenum from)1552 TextureEnvMode FromGLenum<TextureEnvMode>(GLenum from)
1553 {
1554 switch (from)
1555 {
1556 case GL_ADD:
1557 return TextureEnvMode::Add;
1558 case GL_BLEND:
1559 return TextureEnvMode::Blend;
1560 case GL_COMBINE:
1561 return TextureEnvMode::Combine;
1562 case GL_DECAL:
1563 return TextureEnvMode::Decal;
1564 case GL_MODULATE:
1565 return TextureEnvMode::Modulate;
1566 case GL_REPLACE:
1567 return TextureEnvMode::Replace;
1568 default:
1569 return TextureEnvMode::InvalidEnum;
1570 }
1571 }
1572
ToGLenum(TextureEnvMode from)1573 GLenum ToGLenum(TextureEnvMode from)
1574 {
1575 switch (from)
1576 {
1577 case TextureEnvMode::Add:
1578 return GL_ADD;
1579 case TextureEnvMode::Blend:
1580 return GL_BLEND;
1581 case TextureEnvMode::Combine:
1582 return GL_COMBINE;
1583 case TextureEnvMode::Decal:
1584 return GL_DECAL;
1585 case TextureEnvMode::Modulate:
1586 return GL_MODULATE;
1587 case TextureEnvMode::Replace:
1588 return GL_REPLACE;
1589 default:
1590 UNREACHABLE();
1591 return 0;
1592 }
1593 }
1594
operator <<(std::ostream & os,TextureEnvMode value)1595 std::ostream &operator<<(std::ostream &os, TextureEnvMode value)
1596 {
1597 switch (value)
1598 {
1599 case TextureEnvMode::Add:
1600 os << "GL_ADD";
1601 break;
1602 case TextureEnvMode::Blend:
1603 os << "GL_BLEND";
1604 break;
1605 case TextureEnvMode::Combine:
1606 os << "GL_COMBINE";
1607 break;
1608 case TextureEnvMode::Decal:
1609 os << "GL_DECAL";
1610 break;
1611 case TextureEnvMode::Modulate:
1612 os << "GL_MODULATE";
1613 break;
1614 case TextureEnvMode::Replace:
1615 os << "GL_REPLACE";
1616 break;
1617 default:
1618 os << "GL_INVALID_ENUM";
1619 break;
1620 }
1621 return os;
1622 }
1623
1624 template <>
FromGLenum(GLenum from)1625 TextureEnvParameter FromGLenum<TextureEnvParameter>(GLenum from)
1626 {
1627 switch (from)
1628 {
1629 case GL_TEXTURE_ENV_MODE:
1630 return TextureEnvParameter::Mode;
1631 case GL_TEXTURE_ENV_COLOR:
1632 return TextureEnvParameter::Color;
1633 case GL_COMBINE_RGB:
1634 return TextureEnvParameter::CombineRgb;
1635 case GL_COMBINE_ALPHA:
1636 return TextureEnvParameter::CombineAlpha;
1637 case GL_RGB_SCALE:
1638 return TextureEnvParameter::RgbScale;
1639 case GL_ALPHA_SCALE:
1640 return TextureEnvParameter::AlphaScale;
1641 case GL_SRC0_RGB:
1642 return TextureEnvParameter::Src0Rgb;
1643 case GL_SRC1_RGB:
1644 return TextureEnvParameter::Src1Rgb;
1645 case GL_SRC2_RGB:
1646 return TextureEnvParameter::Src2Rgb;
1647 case GL_SRC0_ALPHA:
1648 return TextureEnvParameter::Src0Alpha;
1649 case GL_SRC1_ALPHA:
1650 return TextureEnvParameter::Src1Alpha;
1651 case GL_SRC2_ALPHA:
1652 return TextureEnvParameter::Src2Alpha;
1653 case GL_OPERAND0_RGB:
1654 return TextureEnvParameter::Op0Rgb;
1655 case GL_OPERAND1_RGB:
1656 return TextureEnvParameter::Op1Rgb;
1657 case GL_OPERAND2_RGB:
1658 return TextureEnvParameter::Op2Rgb;
1659 case GL_OPERAND0_ALPHA:
1660 return TextureEnvParameter::Op0Alpha;
1661 case GL_OPERAND1_ALPHA:
1662 return TextureEnvParameter::Op1Alpha;
1663 case GL_OPERAND2_ALPHA:
1664 return TextureEnvParameter::Op2Alpha;
1665 case GL_COORD_REPLACE_OES:
1666 return TextureEnvParameter::PointCoordReplace;
1667 default:
1668 return TextureEnvParameter::InvalidEnum;
1669 }
1670 }
1671
ToGLenum(TextureEnvParameter from)1672 GLenum ToGLenum(TextureEnvParameter from)
1673 {
1674 switch (from)
1675 {
1676 case TextureEnvParameter::Mode:
1677 return GL_TEXTURE_ENV_MODE;
1678 case TextureEnvParameter::Color:
1679 return GL_TEXTURE_ENV_COLOR;
1680 case TextureEnvParameter::CombineRgb:
1681 return GL_COMBINE_RGB;
1682 case TextureEnvParameter::CombineAlpha:
1683 return GL_COMBINE_ALPHA;
1684 case TextureEnvParameter::RgbScale:
1685 return GL_RGB_SCALE;
1686 case TextureEnvParameter::AlphaScale:
1687 return GL_ALPHA_SCALE;
1688 case TextureEnvParameter::Src0Rgb:
1689 return GL_SRC0_RGB;
1690 case TextureEnvParameter::Src1Rgb:
1691 return GL_SRC1_RGB;
1692 case TextureEnvParameter::Src2Rgb:
1693 return GL_SRC2_RGB;
1694 case TextureEnvParameter::Src0Alpha:
1695 return GL_SRC0_ALPHA;
1696 case TextureEnvParameter::Src1Alpha:
1697 return GL_SRC1_ALPHA;
1698 case TextureEnvParameter::Src2Alpha:
1699 return GL_SRC2_ALPHA;
1700 case TextureEnvParameter::Op0Rgb:
1701 return GL_OPERAND0_RGB;
1702 case TextureEnvParameter::Op1Rgb:
1703 return GL_OPERAND1_RGB;
1704 case TextureEnvParameter::Op2Rgb:
1705 return GL_OPERAND2_RGB;
1706 case TextureEnvParameter::Op0Alpha:
1707 return GL_OPERAND0_ALPHA;
1708 case TextureEnvParameter::Op1Alpha:
1709 return GL_OPERAND1_ALPHA;
1710 case TextureEnvParameter::Op2Alpha:
1711 return GL_OPERAND2_ALPHA;
1712 case TextureEnvParameter::PointCoordReplace:
1713 return GL_COORD_REPLACE_OES;
1714 default:
1715 UNREACHABLE();
1716 return 0;
1717 }
1718 }
1719
operator <<(std::ostream & os,TextureEnvParameter value)1720 std::ostream &operator<<(std::ostream &os, TextureEnvParameter value)
1721 {
1722 switch (value)
1723 {
1724 case TextureEnvParameter::Mode:
1725 os << "GL_TEXTURE_ENV_MODE";
1726 break;
1727 case TextureEnvParameter::Color:
1728 os << "GL_TEXTURE_ENV_COLOR";
1729 break;
1730 case TextureEnvParameter::CombineRgb:
1731 os << "GL_COMBINE_RGB";
1732 break;
1733 case TextureEnvParameter::CombineAlpha:
1734 os << "GL_COMBINE_ALPHA";
1735 break;
1736 case TextureEnvParameter::RgbScale:
1737 os << "GL_RGB_SCALE";
1738 break;
1739 case TextureEnvParameter::AlphaScale:
1740 os << "GL_ALPHA_SCALE";
1741 break;
1742 case TextureEnvParameter::Src0Rgb:
1743 os << "GL_SRC0_RGB";
1744 break;
1745 case TextureEnvParameter::Src1Rgb:
1746 os << "GL_SRC1_RGB";
1747 break;
1748 case TextureEnvParameter::Src2Rgb:
1749 os << "GL_SRC2_RGB";
1750 break;
1751 case TextureEnvParameter::Src0Alpha:
1752 os << "GL_SRC0_ALPHA";
1753 break;
1754 case TextureEnvParameter::Src1Alpha:
1755 os << "GL_SRC1_ALPHA";
1756 break;
1757 case TextureEnvParameter::Src2Alpha:
1758 os << "GL_SRC2_ALPHA";
1759 break;
1760 case TextureEnvParameter::Op0Rgb:
1761 os << "GL_OPERAND0_RGB";
1762 break;
1763 case TextureEnvParameter::Op1Rgb:
1764 os << "GL_OPERAND1_RGB";
1765 break;
1766 case TextureEnvParameter::Op2Rgb:
1767 os << "GL_OPERAND2_RGB";
1768 break;
1769 case TextureEnvParameter::Op0Alpha:
1770 os << "GL_OPERAND0_ALPHA";
1771 break;
1772 case TextureEnvParameter::Op1Alpha:
1773 os << "GL_OPERAND1_ALPHA";
1774 break;
1775 case TextureEnvParameter::Op2Alpha:
1776 os << "GL_OPERAND2_ALPHA";
1777 break;
1778 case TextureEnvParameter::PointCoordReplace:
1779 os << "GL_COORD_REPLACE_OES";
1780 break;
1781 default:
1782 os << "GL_INVALID_ENUM";
1783 break;
1784 }
1785 return os;
1786 }
1787
1788 template <>
FromGLenum(GLenum from)1789 TextureEnvTarget FromGLenum<TextureEnvTarget>(GLenum from)
1790 {
1791 switch (from)
1792 {
1793 case GL_TEXTURE_ENV:
1794 return TextureEnvTarget::Env;
1795 case GL_POINT_SPRITE_OES:
1796 return TextureEnvTarget::PointSprite;
1797 default:
1798 return TextureEnvTarget::InvalidEnum;
1799 }
1800 }
1801
ToGLenum(TextureEnvTarget from)1802 GLenum ToGLenum(TextureEnvTarget from)
1803 {
1804 switch (from)
1805 {
1806 case TextureEnvTarget::Env:
1807 return GL_TEXTURE_ENV;
1808 case TextureEnvTarget::PointSprite:
1809 return GL_POINT_SPRITE_OES;
1810 default:
1811 UNREACHABLE();
1812 return 0;
1813 }
1814 }
1815
operator <<(std::ostream & os,TextureEnvTarget value)1816 std::ostream &operator<<(std::ostream &os, TextureEnvTarget value)
1817 {
1818 switch (value)
1819 {
1820 case TextureEnvTarget::Env:
1821 os << "GL_TEXTURE_ENV";
1822 break;
1823 case TextureEnvTarget::PointSprite:
1824 os << "GL_POINT_SPRITE_OES";
1825 break;
1826 default:
1827 os << "GL_INVALID_ENUM";
1828 break;
1829 }
1830 return os;
1831 }
1832
1833 template <>
FromGLenum(GLenum from)1834 TextureOp FromGLenum<TextureOp>(GLenum from)
1835 {
1836 switch (from)
1837 {
1838 case GL_ONE_MINUS_SRC_ALPHA:
1839 return TextureOp::OneMinusSrcAlpha;
1840 case GL_ONE_MINUS_SRC_COLOR:
1841 return TextureOp::OneMinusSrcColor;
1842 case GL_SRC_ALPHA:
1843 return TextureOp::SrcAlpha;
1844 case GL_SRC_COLOR:
1845 return TextureOp::SrcColor;
1846 default:
1847 return TextureOp::InvalidEnum;
1848 }
1849 }
1850
ToGLenum(TextureOp from)1851 GLenum ToGLenum(TextureOp from)
1852 {
1853 switch (from)
1854 {
1855 case TextureOp::OneMinusSrcAlpha:
1856 return GL_ONE_MINUS_SRC_ALPHA;
1857 case TextureOp::OneMinusSrcColor:
1858 return GL_ONE_MINUS_SRC_COLOR;
1859 case TextureOp::SrcAlpha:
1860 return GL_SRC_ALPHA;
1861 case TextureOp::SrcColor:
1862 return GL_SRC_COLOR;
1863 default:
1864 UNREACHABLE();
1865 return 0;
1866 }
1867 }
1868
operator <<(std::ostream & os,TextureOp value)1869 std::ostream &operator<<(std::ostream &os, TextureOp value)
1870 {
1871 switch (value)
1872 {
1873 case TextureOp::OneMinusSrcAlpha:
1874 os << "GL_ONE_MINUS_SRC_ALPHA";
1875 break;
1876 case TextureOp::OneMinusSrcColor:
1877 os << "GL_ONE_MINUS_SRC_COLOR";
1878 break;
1879 case TextureOp::SrcAlpha:
1880 os << "GL_SRC_ALPHA";
1881 break;
1882 case TextureOp::SrcColor:
1883 os << "GL_SRC_COLOR";
1884 break;
1885 default:
1886 os << "GL_INVALID_ENUM";
1887 break;
1888 }
1889 return os;
1890 }
1891
1892 template <>
FromGLenum(GLenum from)1893 TextureSrc FromGLenum<TextureSrc>(GLenum from)
1894 {
1895 switch (from)
1896 {
1897 case GL_CONSTANT:
1898 return TextureSrc::Constant;
1899 case GL_PREVIOUS:
1900 return TextureSrc::Previous;
1901 case GL_PRIMARY_COLOR:
1902 return TextureSrc::PrimaryColor;
1903 case GL_TEXTURE:
1904 return TextureSrc::Texture;
1905 default:
1906 return TextureSrc::InvalidEnum;
1907 }
1908 }
1909
ToGLenum(TextureSrc from)1910 GLenum ToGLenum(TextureSrc from)
1911 {
1912 switch (from)
1913 {
1914 case TextureSrc::Constant:
1915 return GL_CONSTANT;
1916 case TextureSrc::Previous:
1917 return GL_PREVIOUS;
1918 case TextureSrc::PrimaryColor:
1919 return GL_PRIMARY_COLOR;
1920 case TextureSrc::Texture:
1921 return GL_TEXTURE;
1922 default:
1923 UNREACHABLE();
1924 return 0;
1925 }
1926 }
1927
operator <<(std::ostream & os,TextureSrc value)1928 std::ostream &operator<<(std::ostream &os, TextureSrc value)
1929 {
1930 switch (value)
1931 {
1932 case TextureSrc::Constant:
1933 os << "GL_CONSTANT";
1934 break;
1935 case TextureSrc::Previous:
1936 os << "GL_PREVIOUS";
1937 break;
1938 case TextureSrc::PrimaryColor:
1939 os << "GL_PRIMARY_COLOR";
1940 break;
1941 case TextureSrc::Texture:
1942 os << "GL_TEXTURE";
1943 break;
1944 default:
1945 os << "GL_INVALID_ENUM";
1946 break;
1947 }
1948 return os;
1949 }
1950
1951 template <>
FromGLenum(GLenum from)1952 TextureTarget FromGLenum<TextureTarget>(GLenum from)
1953 {
1954 switch (from)
1955 {
1956 case GL_TEXTURE_2D:
1957 return TextureTarget::_2D;
1958 case GL_TEXTURE_2D_ARRAY:
1959 return TextureTarget::_2DArray;
1960 case GL_TEXTURE_2D_MULTISAMPLE:
1961 return TextureTarget::_2DMultisample;
1962 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES:
1963 return TextureTarget::_2DMultisampleArray;
1964 case GL_TEXTURE_3D:
1965 return TextureTarget::_3D;
1966 case GL_TEXTURE_EXTERNAL_OES:
1967 return TextureTarget::External;
1968 case GL_TEXTURE_RECTANGLE_ANGLE:
1969 return TextureTarget::Rectangle;
1970 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1971 return TextureTarget::CubeMapPositiveX;
1972 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1973 return TextureTarget::CubeMapNegativeX;
1974 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1975 return TextureTarget::CubeMapPositiveY;
1976 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1977 return TextureTarget::CubeMapNegativeY;
1978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1979 return TextureTarget::CubeMapPositiveZ;
1980 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1981 return TextureTarget::CubeMapNegativeZ;
1982 default:
1983 return TextureTarget::InvalidEnum;
1984 }
1985 }
1986
ToGLenum(TextureTarget from)1987 GLenum ToGLenum(TextureTarget from)
1988 {
1989 switch (from)
1990 {
1991 case TextureTarget::_2D:
1992 return GL_TEXTURE_2D;
1993 case TextureTarget::_2DArray:
1994 return GL_TEXTURE_2D_ARRAY;
1995 case TextureTarget::_2DMultisample:
1996 return GL_TEXTURE_2D_MULTISAMPLE;
1997 case TextureTarget::_2DMultisampleArray:
1998 return GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES;
1999 case TextureTarget::_3D:
2000 return GL_TEXTURE_3D;
2001 case TextureTarget::External:
2002 return GL_TEXTURE_EXTERNAL_OES;
2003 case TextureTarget::Rectangle:
2004 return GL_TEXTURE_RECTANGLE_ANGLE;
2005 case TextureTarget::CubeMapPositiveX:
2006 return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
2007 case TextureTarget::CubeMapNegativeX:
2008 return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
2009 case TextureTarget::CubeMapPositiveY:
2010 return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
2011 case TextureTarget::CubeMapNegativeY:
2012 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
2013 case TextureTarget::CubeMapPositiveZ:
2014 return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
2015 case TextureTarget::CubeMapNegativeZ:
2016 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
2017 default:
2018 UNREACHABLE();
2019 return 0;
2020 }
2021 }
2022
operator <<(std::ostream & os,TextureTarget value)2023 std::ostream &operator<<(std::ostream &os, TextureTarget value)
2024 {
2025 switch (value)
2026 {
2027 case TextureTarget::_2D:
2028 os << "GL_TEXTURE_2D";
2029 break;
2030 case TextureTarget::_2DArray:
2031 os << "GL_TEXTURE_2D_ARRAY";
2032 break;
2033 case TextureTarget::_2DMultisample:
2034 os << "GL_TEXTURE_2D_MULTISAMPLE";
2035 break;
2036 case TextureTarget::_2DMultisampleArray:
2037 os << "GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES";
2038 break;
2039 case TextureTarget::_3D:
2040 os << "GL_TEXTURE_3D";
2041 break;
2042 case TextureTarget::External:
2043 os << "GL_TEXTURE_EXTERNAL_OES";
2044 break;
2045 case TextureTarget::Rectangle:
2046 os << "GL_TEXTURE_RECTANGLE_ANGLE";
2047 break;
2048 case TextureTarget::CubeMapPositiveX:
2049 os << "GL_TEXTURE_CUBE_MAP_POSITIVE_X";
2050 break;
2051 case TextureTarget::CubeMapNegativeX:
2052 os << "GL_TEXTURE_CUBE_MAP_NEGATIVE_X";
2053 break;
2054 case TextureTarget::CubeMapPositiveY:
2055 os << "GL_TEXTURE_CUBE_MAP_POSITIVE_Y";
2056 break;
2057 case TextureTarget::CubeMapNegativeY:
2058 os << "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y";
2059 break;
2060 case TextureTarget::CubeMapPositiveZ:
2061 os << "GL_TEXTURE_CUBE_MAP_POSITIVE_Z";
2062 break;
2063 case TextureTarget::CubeMapNegativeZ:
2064 os << "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z";
2065 break;
2066 default:
2067 os << "GL_INVALID_ENUM";
2068 break;
2069 }
2070 return os;
2071 }
2072
2073 template <>
FromGLenum(GLenum from)2074 TextureType FromGLenum<TextureType>(GLenum from)
2075 {
2076 switch (from)
2077 {
2078 case GL_TEXTURE_2D:
2079 return TextureType::_2D;
2080 case GL_TEXTURE_2D_ARRAY:
2081 return TextureType::_2DArray;
2082 case GL_TEXTURE_2D_MULTISAMPLE:
2083 return TextureType::_2DMultisample;
2084 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES:
2085 return TextureType::_2DMultisampleArray;
2086 case GL_TEXTURE_3D:
2087 return TextureType::_3D;
2088 case GL_TEXTURE_EXTERNAL_OES:
2089 return TextureType::External;
2090 case GL_TEXTURE_RECTANGLE_ANGLE:
2091 return TextureType::Rectangle;
2092 case GL_TEXTURE_CUBE_MAP:
2093 return TextureType::CubeMap;
2094 default:
2095 return TextureType::InvalidEnum;
2096 }
2097 }
2098
ToGLenum(TextureType from)2099 GLenum ToGLenum(TextureType from)
2100 {
2101 switch (from)
2102 {
2103 case TextureType::_2D:
2104 return GL_TEXTURE_2D;
2105 case TextureType::_2DArray:
2106 return GL_TEXTURE_2D_ARRAY;
2107 case TextureType::_2DMultisample:
2108 return GL_TEXTURE_2D_MULTISAMPLE;
2109 case TextureType::_2DMultisampleArray:
2110 return GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES;
2111 case TextureType::_3D:
2112 return GL_TEXTURE_3D;
2113 case TextureType::External:
2114 return GL_TEXTURE_EXTERNAL_OES;
2115 case TextureType::Rectangle:
2116 return GL_TEXTURE_RECTANGLE_ANGLE;
2117 case TextureType::CubeMap:
2118 return GL_TEXTURE_CUBE_MAP;
2119 default:
2120 UNREACHABLE();
2121 return 0;
2122 }
2123 }
2124
operator <<(std::ostream & os,TextureType value)2125 std::ostream &operator<<(std::ostream &os, TextureType value)
2126 {
2127 switch (value)
2128 {
2129 case TextureType::_2D:
2130 os << "GL_TEXTURE_2D";
2131 break;
2132 case TextureType::_2DArray:
2133 os << "GL_TEXTURE_2D_ARRAY";
2134 break;
2135 case TextureType::_2DMultisample:
2136 os << "GL_TEXTURE_2D_MULTISAMPLE";
2137 break;
2138 case TextureType::_2DMultisampleArray:
2139 os << "GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES";
2140 break;
2141 case TextureType::_3D:
2142 os << "GL_TEXTURE_3D";
2143 break;
2144 case TextureType::External:
2145 os << "GL_TEXTURE_EXTERNAL_OES";
2146 break;
2147 case TextureType::Rectangle:
2148 os << "GL_TEXTURE_RECTANGLE_ANGLE";
2149 break;
2150 case TextureType::CubeMap:
2151 os << "GL_TEXTURE_CUBE_MAP";
2152 break;
2153 default:
2154 os << "GL_INVALID_ENUM";
2155 break;
2156 }
2157 return os;
2158 }
2159
2160 template <>
FromGLenum(GLenum from)2161 VertexArrayType FromGLenum<VertexArrayType>(GLenum from)
2162 {
2163 switch (from)
2164 {
2165 case GL_COLOR_ARRAY:
2166 return VertexArrayType::Color;
2167 case GL_NORMAL_ARRAY:
2168 return VertexArrayType::Normal;
2169 case GL_POINT_SIZE_ARRAY_OES:
2170 return VertexArrayType::PointSize;
2171 case GL_TEXTURE_COORD_ARRAY:
2172 return VertexArrayType::TextureCoord;
2173 case GL_VERTEX_ARRAY:
2174 return VertexArrayType::Vertex;
2175 default:
2176 return VertexArrayType::InvalidEnum;
2177 }
2178 }
2179
ToGLenum(VertexArrayType from)2180 GLenum ToGLenum(VertexArrayType from)
2181 {
2182 switch (from)
2183 {
2184 case VertexArrayType::Color:
2185 return GL_COLOR_ARRAY;
2186 case VertexArrayType::Normal:
2187 return GL_NORMAL_ARRAY;
2188 case VertexArrayType::PointSize:
2189 return GL_POINT_SIZE_ARRAY_OES;
2190 case VertexArrayType::TextureCoord:
2191 return GL_TEXTURE_COORD_ARRAY;
2192 case VertexArrayType::Vertex:
2193 return GL_VERTEX_ARRAY;
2194 default:
2195 UNREACHABLE();
2196 return 0;
2197 }
2198 }
2199
operator <<(std::ostream & os,VertexArrayType value)2200 std::ostream &operator<<(std::ostream &os, VertexArrayType value)
2201 {
2202 switch (value)
2203 {
2204 case VertexArrayType::Color:
2205 os << "GL_COLOR_ARRAY";
2206 break;
2207 case VertexArrayType::Normal:
2208 os << "GL_NORMAL_ARRAY";
2209 break;
2210 case VertexArrayType::PointSize:
2211 os << "GL_POINT_SIZE_ARRAY_OES";
2212 break;
2213 case VertexArrayType::TextureCoord:
2214 os << "GL_TEXTURE_COORD_ARRAY";
2215 break;
2216 case VertexArrayType::Vertex:
2217 os << "GL_VERTEX_ARRAY";
2218 break;
2219 default:
2220 os << "GL_INVALID_ENUM";
2221 break;
2222 }
2223 return os;
2224 }
2225
2226 template <>
FromGLenum(GLenum from)2227 WrapMode FromGLenum<WrapMode>(GLenum from)
2228 {
2229 switch (from)
2230 {
2231 case GL_CLAMP_TO_EDGE:
2232 return WrapMode::ClampToEdge;
2233 case GL_CLAMP_TO_BORDER:
2234 return WrapMode::ClampToBorder;
2235 case GL_MIRRORED_REPEAT:
2236 return WrapMode::MirroredRepeat;
2237 case GL_REPEAT:
2238 return WrapMode::Repeat;
2239 default:
2240 return WrapMode::InvalidEnum;
2241 }
2242 }
2243
ToGLenum(WrapMode from)2244 GLenum ToGLenum(WrapMode from)
2245 {
2246 switch (from)
2247 {
2248 case WrapMode::ClampToEdge:
2249 return GL_CLAMP_TO_EDGE;
2250 case WrapMode::ClampToBorder:
2251 return GL_CLAMP_TO_BORDER;
2252 case WrapMode::MirroredRepeat:
2253 return GL_MIRRORED_REPEAT;
2254 case WrapMode::Repeat:
2255 return GL_REPEAT;
2256 default:
2257 UNREACHABLE();
2258 return 0;
2259 }
2260 }
2261
operator <<(std::ostream & os,WrapMode value)2262 std::ostream &operator<<(std::ostream &os, WrapMode value)
2263 {
2264 switch (value)
2265 {
2266 case WrapMode::ClampToEdge:
2267 os << "GL_CLAMP_TO_EDGE";
2268 break;
2269 case WrapMode::ClampToBorder:
2270 os << "GL_CLAMP_TO_BORDER";
2271 break;
2272 case WrapMode::MirroredRepeat:
2273 os << "GL_MIRRORED_REPEAT";
2274 break;
2275 case WrapMode::Repeat:
2276 os << "GL_REPEAT";
2277 break;
2278 default:
2279 os << "GL_INVALID_ENUM";
2280 break;
2281 }
2282 return os;
2283 }
2284
2285 } // namespace gl
2286