fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / glEnumMapper / createGLEnumMaps.pl
blob8919ae7993484b7a2da933756f244d1c0132e54d
1 #!/usr/bin/perl
3 use strict;
5 my %gl_define_list_one;
6 my %gl_define_list_two;
8 my @exclude_list =
10 "GL_VERSION_.*",
11 "GL_NO_ERROR",
12 "GL_INVALID_ENUM",
13 "GL_INVALID_VALUE",
14 "GL_INVALID_OPERATION",
15 "GL_STACK_OVERFLOW",
16 "GL_STACK_UNDERFLOW",
17 "GL_OUT_OF_MEMORY",
18 "GL_TABLE_TOO_LARGE",
19 "GL_GLEXT_VERSION",
20 "GL_TIMEOUT_IGNORED"
23 my @match_one_way_list =
25 "RELATIVE_VERTICAL_LINE_TO_NV\$",
26 "RELATIVE_CUBIC_CURVE_TO_NV\$",
27 "RELATIVE_QUADRATIC_CURVE_TO_NV\$",
29 "VERTICAL_LINE_TO_NV\$",
30 "CUBIC_CURVE_TO_NV\$",
31 "QUADRATIC_CURVE_TO_NV\$",
33 "SMOOTH_QUADRATIC_CURVE_TO_NV\$",
35 "CURRENT_OCCLUSION_QUERY_ID_NV\$",
37 "UNSIGNED_INT64_NV\$",
39 "CURRENT_TIME_NV\$",
40 "PROGRAM_ERROR_STRING_NV\$",
42 "PIXEL_COUNT_AVAILABLE_NV\$",
43 "PIXEL_COUNT_NV\$",
45 "PROGRAM_ERROR_POSITION_NV\$",
47 "CURRENT_MATRIX_STACK_DEPTH_NV\$",
48 "CURRENT_MATRIX_NV\$",
49 "MAX_TRACK_MATRICES_NV\$",
50 "MAX_TRACK_MATRIX_STACK_DEPTH_NV\$",
52 "PIXEL_COUNTER_BITS_NV\$",
54 "OFFSET_TEXTURE_2D_MATRIX_NV\$",
55 "OFFSET_TEXTURE_2D_BIAS_NV\$",
57 "VERTEX_PROGRAM_NV\$",
58 "PROGRAM_STRING_NV\$",
59 "PROGRAM_LENGTH_NV\$",
61 "VERTEX_PROGRAM_POINT_SIZE_NV\$",
63 "OFFSET_TEXTURE_2D_SCALE_NV\$",
65 "RENDERBUFFER_COVERAGE_SAMPLES_NV\$",
67 "MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV\$",
69 "MAP2_VERTEX_ATTRIB7_4_NV\$",
71 "CURRENT_ATTRIB_NV\$",
73 "ATTRIB_ARRAY_POINTER_NV\$",
74 "ATTRIB_ARRAY_STRIDE_NV\$",
75 "ATTRIB_ARRAY_TYPE_NV\$",
76 "ATTRIB_ARRAY_SIZE_NV\$",
78 "TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV\$",
79 "TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV\$",
81 "FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV\$",
85 "ALPHA_FLOAT16_ATI\$",
86 "ALPHA_FLOAT32_ATI\$",
88 "INTENSITY_FLOAT16_ATI\$",
89 "INTENSITY_FLOAT32_ATI\$",
91 "LUMINANCE_FLOAT16_ATI\$",
92 "LUMINANCE_FLOAT32_ATI\$",
94 "LUMINANCE_ALPHA_FLOAT16_ATI\$",
95 "LUMINANCE_ALPHA_FLOAT32_ATI\$",
97 "RGB_FLOAT16_ATI\$",
98 "RGB_FLOAT32_ATI\$",
100 "RGBA_FLOAT16_ATI\$",
101 "RGBA_FLOAT32_ATI\$",
103 "RGBA_FLOAT_MODE_ATI\$",
104 "MIRROR_CLAMP_ATI\$",
105 "SATURATE_BIT_ATI\$",
107 "OBJECT_BUFFER_SIZE_ATI\$",
108 "OBJECT_BUFFER_USAGE_ATI\$",
113 "VIRTUAL_PAGE_SIZE_X_AMD\$",
114 "VIRTUAL_PAGE_SIZE_Y_AMD\$",
115 "VIRTUAL_PAGE_SIZE_Z_AMD\$",
117 "MIN_SPARSE_LEVEL_AMD\$",
118 "MAX_SPARSE_TEXTURE_SIZE_AMD\$",
119 "MAX_SPARSE_3D_TEXTURE_SIZE_AMD\$",
121 "DEBUG_SEVERITY_HIGH_AMD\$",
122 "DEBUG_SEVERITY_LOW_AMD\$",
123 "DEBUG_SEVERITY_MEDIUM_AMD\$",
124 "DEBUG_LOGGED_MESSAGES_AMD\$",
125 "MAX_DEBUG_LOGGED_MESSAGES_AMD\$",
126 "MAX_DEBUG_MESSAGE_LENGTH_AMD\$",
128 "QUERY_OBJECT_AMD\$",
129 "QUERY_BUFFER_AMD\$",
130 "QUERY_BUFFER_BINDING_AMD\$",
131 "QUERY_RESULT_NO_WAIT_AMD\$",
133 "VERTEX_ARRAY_OBJECT_AMD\$",
134 "DATA_BUFFER_AMD\$",
136 "MAX_COMPUTE_FIXED_GROUP_SIZE_ARB\$",
137 "MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB\$",
139 "MAX_VARYING_FLOATS_ARB\$",
141 "MODELVIEW0_ARB\$",
143 "OBJECT_DELETE_STATUS_ARB\$",
144 "OBJECT_ATTACHED_OBJECTS_ARB\$",
145 "OBJECT_ACTIVE_ATTRIBUTES_ARB\$",
146 "OBJECT_LINK_STATUS_ARB\$",
147 "OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\$",
148 "OBJECT_INFO_LOG_LENGTH_ARB\$",
149 "OBJECT_SUBTYPE_ARB\$",
150 "OBJECT_SHADER_SOURCE_LENGTH_ARB\$",
151 "OBJECT_VALIDATE_STATUS_ARB\$",
152 "OBJECT_COMPILE_STATUS_ARB\$",
153 "OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\$",
154 "OBJECT_ACTIVE_UNIFORMS_ARB\$",
156 "FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\$",
158 "SOURCE0_RGB_ARB\$",
159 "SOURCE0_ALPHA_ARB\$",
160 "SOURCE1_RGB_ARB\$",
161 "SOURCE1_ALPHA_ARB\$",
162 "SOURCE2_RGB_ARB\$",
163 "SOURCE2_ALPHA_ARB\$",
165 "VERTEX_PROGRAM_POINT_SIZE_ARB\$",
169 "TEXTURE_1D_BINDING_EXT\$",
170 "TEXTURE_2D_BINDING_EXT\$",
171 "TEXTURE_3D_BINDING_EXT\$",
173 "FRAMEBUFFER_BINDING_EXT\$",
175 "TEXTURE_BUFFER_FORMAT_EXT\$",
177 "MAX_VERTEX_VARYING_COMPONENTS_EXT\$",
178 "MAX_GEOMETRY_VARYING_COMPONENTS_EXT\$",
179 "MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT\$",
181 "FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\$",
183 "MODELVIEW0_MATRIX_EXT\$",
184 "MODELVIEW0_EXT\$",
185 "MODELVIEW1_EXT\$",
186 "MODELVIEW0_STACK_DEPTH_EXT\$",
188 "PROGRAM_OBJECT_EXT\$",
189 "SHADER_OBJECT_EXT\$",
191 "COMPARE_REF_DEPTH_TO_TEXTURE_EXT\$",
193 "COMPRESSED_RED_GREEN_RGTC2_EXT\$",
194 "COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT\$",
196 "FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT\$",
198 "POLYGON_OFFSET_EXT\$",
199 "DISTANCE_ATTENUATION_EXT\$",
200 "BLEND_EQUATION_EXT\$",
202 "SAMPLE_MASK_INVERT_EXT\$",
203 "SAMPLE_ALPHA_TO_MASK_EXT\$",
204 "SAMPLE_ALPHA_TO_ONE_EXT\$",
206 "FOG_COORDINATE_ARRAY_EXT\$",
207 "FOG_COORDINATE_ARRAY_POINTER_EXT\$",
208 "FOG_COORDINATE_ARRAY_STRIDE_EXT\$",
209 "FOG_COORDINATE_ARRAY_TYPE_EXT\$",
210 "FOG_COORDINATE_SOURCE_EXT\$",
211 "FOG_COORDINATE_EXT\$",
212 "CURRENT_FOG_COORDINATE_EXT\$",
214 "SOURCE0_ALPHA_EXT\$",
215 "SOURCE0_RGB_EXT\$",
216 "SOURCE1_ALPHA_EXT\$",
217 "SOURCE1_RGB_EXT\$",
218 "SOURCE2_ALPHA_EXT\$",
219 "SOURCE2_RGB_EXT\$",
221 "LAYOUT_DEFAULT_INTEL\$",
224 "UNSIGNED_SHORT_8_8_APPLE\$",
225 "UNSIGNED_SHORT_8_8_REV_APPLE\$",
226 "HALF_APPLE\$",
228 "ALPHA_FLOAT16_APPLE\$",
229 "ALPHA_FLOAT32_APPLE\$",
231 "INTENSITY_FLOAT16_APPLE\$",
232 "INTENSITY_FLOAT32_APPLE\$",
234 "LUMINANCE_FLOAT16_APPLE\$",
235 "LUMINANCE_FLOAT32_APPLE\$",
237 "LUMINANCE_ALPHA_FLOAT16_APPLE\$",
238 "LUMINANCE_ALPHA_FLOAT32_APPLE\$",
240 "RGB_FLOAT16_APPLE\$",
241 "RGB_FLOAT32_APPLE\$",
243 "RGBA_FLOAT16_APPLE\$",
244 "RGBA_FLOAT32_APPLE\$",
246 "VERTEX_ARRAY_BINDING_APPLE\$",
247 "VERTEX_ARRAY_RANGE_APPLE\$",
248 "VERTEX_ARRAY_RANGE_LENGTH_APPLE\$",
249 "VERTEX_ARRAY_RANGE_POINTER_APPLE\$",
250 "VERTEX_ARRAY_STORAGE_HINT_APPLE\$",
255 "1PASS_SGIS\$",
256 "2PASS_0_SGIS\$",
257 "2PASS_1_SGIS\$",
258 "4PASS_0_SGIS\$",
259 "4PASS_1_SGIS\$",
260 "4PASS_2_SGIS\$",
261 "4PASS_3_SGIS\$",
263 "SAMPLE_PATTERN_SGIS\$",
264 "SAMPLE_MASK_INVERT_SGIS\$",
265 "SAMPLE_ALPHA_TO_MASK_SGIS\$",
266 "SAMPLE_ALPHA_TO_ONE_SGIS\$",
268 "SHADOW_AMBIENT_SGIX\$",
269 "DISTANCE_ATTENUATION_SGIS\$",
273 "REPLACE_OLDEST_SUN\$",
276 "FIXED_OES\$",
278 "IMPLEMENTATION_COLOR_READ_TYPE_OES\$",
279 "IMPLEMENTATION_COLOR_READ_FORMAT_OES\$",
283 "TEXTURE_COMPONENTS\$",
284 "LOGIC_OP\$",
285 "BLEND_EQUATION\$",
286 "COMPARE_REF_TO_TEXTURE\$",
289 "CLIP_DISTANCE0\$",
290 "CLIP_DISTANCE1\$",
291 "CLIP_DISTANCE2\$",
292 "CLIP_DISTANCE3\$",
293 "CLIP_DISTANCE4\$",
294 "CLIP_DISTANCE5\$",
295 "MAX_CLIP_DISTANCES\$",
297 "TRANSFORM_FEEDBACK_BUFFER_ACTIVE\$",
298 "TRANSFORM_FEEDBACK_BUFFER_PAUSED\$",
300 "MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS\$",
301 "MAX_VARYING_FLOATS\$",
303 "VERTEX_PROGRAM_POINT_SIZE\$",
304 "POINT_SIZE_GRANULARITY\$",
305 "POINT_SIZE_RANGE\$",
307 "LINE_WIDTH_RANGE\$",
308 "LINE_WIDTH_GRANULARITY\$",
310 "SOURCE0_ALPHA\$",
311 "SOURCE0_RGB\$",
312 "SOURCE1_ALPHA\$",
313 "SOURCE1_RGB\$",
314 "SOURCE2_ALPHA\$",
315 "SOURCE2_RGB\$",
317 "FOG_COORDINATE\$",
318 "FOG_COORDINATE_ARRAY\$",
319 "FOG_COORDINATE_ARRAY_STRIDE\$",
320 "FOG_COORDINATE_ARRAY_BUFFER_BINDING\$",
321 "FOG_COORDINATE_ARRAY_POINTER\$",
322 "FOG_COORDINATE_ARRAY_TYPE\$",
323 "FOG_COORDINATE_SOURCE\$",
325 "CURRENT_FOG_COORDINATE\$",
327 "COPY_READ_BUFFER\$",
328 "COPY_WRITE_BUFFER\$",
329 "FRAMEBUFFER_BINDING\$",
330 "TEXTURE_BUFFER_BINDING\$",
333 # 0 POINTS
335 "NONE\$",
336 "CLOSE_PATH_NV\$",
337 "ZERO\$",
338 "FALSE\$",
340 # 1 LINES
342 "TRUE\$",
343 "ONE\$",
345 "CLIENT_PIXEL_STORE_BIT\$",
346 "VERTEX_ATTRIB_ARRAY_BARRIER_BIT\$",
347 "SYNC_FLUSH_COMMANDS_BIT\$",
348 "VERTEX_SHADER_BIT\$",
349 "MAP_READ_BIT\$",
351 "CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT\$",
352 "CONTEXT_CORE_PROFILE_BIT\$",
354 "CURRENT_BIT\$",
356 "VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT\$",
358 "2X_BIT_ATI\$",
359 "RED_BIT_ATI\$",
361 "TEXTURE_STORAGE_SPARSE_BIT_AMD\$",
363 "BOLD_BIT_NV\$",
364 "GLYPH_WIDTH_BIT_NV\$",
366 "TEXTURE_DEFORMATION_BIT_SGIX\$",
368 "RESTART_SUN\$",
370 "LAYOUT_LINEAR_INTEL\$",
373 # 2 LINE_LOOP
375 "FRAGMENT_SHADER_BIT\$",
376 "MAP_WRITE_BIT\$",
377 "POINT_BIT\$",
378 "CONTEXT_COMPATIBILITY_PROFILE_BIT\$",
379 "CONTEXT_FLAG_DEBUG_BIT\$",
380 "ELEMENT_ARRAY_BARRIER_BIT\$",
381 "CLIENT_VERTEX_ARRAY_BIT\$",
383 "ELEMENT_ARRAY_BARRIER_BIT_EXT\$",
385 "COMP_BIT_ATI\$",
386 "GREEN_BIT_ATI\$",
387 "4X_BIT_ATI\$",
389 "MOVE_TO_NV\$",
390 "ITALIC_BIT_NV\$",
391 "GLYPH_HEIGHT_BIT_NV\$",
393 "GEOMETRY_DEFORMATION_BIT_SGIX\$",
395 "REPLACE_MIDDLE_SUN\$",
397 "LAYOUT_LINEAR_CPU_CACHED_INTEL\$",
400 # 3 LINE_STRIP
402 "RELATIVE_MOVE_TO_NV\$",
404 # 4 TRIANGLES
406 "LINE_BIT\$",
407 "MAP_INVALIDATE_RANGE_BIT\$",
408 "GEOMETRY_SHADER_BIT\$",
409 "UNIFORM_BARRIER_BIT\$",
411 "CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB\$",
413 "UNIFORM_BARRIER_BIT_EXT\$",
415 "NEGATE_BIT_ATI\$",
416 "BLUE_BIT_ATI\$",
417 "8X_BIT_ATI\$",
419 "GLYPH_HORIZONTAL_BEARING_X_BIT_NV\$",
420 "LINE_TO_NV\$",
422 "VERTEX23_BIT_PGI\$",
425 # 5 TRIANGLE_STRIP
427 "RELATIVE_LINE_TO_NV\$",
429 # 6 TRIANGLE_FAN
431 "HORIZONTAL_LINE_TO_NV\$",
433 # 7 QUADS
435 "RELATIVE_HORIZONTAL_LINE_TO_NV\$",
437 # 8 QUAD_STRIP
439 "MAP_INVALIDATE_BUFFER_BIT\$",
440 "TEXTURE_FETCH_BARRIER_BIT\$",
441 "TESS_CONTROL_SHADER_BIT\$",
442 "POLYGON_BIT\$",
444 "TEXTURE_FETCH_BARRIER_BIT_EXT\$",
446 "BIAS_BIT_ATI\$",
447 "HALF_BIT_ATI\$",
449 "GLYPH_HORIZONTAL_BEARING_Y_BIT_NV\$",
451 "VERTEX4_BIT_PGI\$",
453 # 10 TESS_EVALUATION_SHADER_BIT\$",
455 "POLYGON_STIPPLE_BIT\$",
456 "MAP_FLUSH_EXPLICIT_BIT\$",
458 "GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV\$",
459 "SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV\$",
461 "QUARTER_BIT_ATI\$",
464 # 20 COMPUTE_SHADER_BIT
466 "PIXEL_MODE_BIT\$",
467 "SHADER_IMAGE_ACCESS_BARRIER_BIT\$",
468 "MAP_UNSYNCHRONIZED_BIT\$",
470 "SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT\$",
472 "EIGHTH_BIT_ATI\$",
474 "GLYPH_VERTICAL_BEARING_X_BIT_NV\$",
477 # 40 LIGHTING_BIT
479 "COMMAND_BARRIER_BIT\$",
480 "MAP_PERSISTENT_BIT\$",
482 "COMMAND_BARRIER_BIT_EXT\$",
484 "GLYPH_VERTICAL_BEARING_Y_BIT_NV\$",
486 # 80 PIXEL_BUFFER_BARRIER_BIT
488 "FOG_BIT\$",
489 "MAP_COHERENT_BIT\$",
491 "GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV\$",
494 # 100 ACCUM
496 "DEPTH_BUFFER_BIT\$",
497 "TEXTURE_UPDATE_BARRIER_BIT\$",
498 "DYNAMIC_STORAGE_BIT\$",
500 "TEXTURE_UPDATE_BARRIER_BIT_EXT\$",
502 "GLYPH_HAS_KERNING_BIT_NV\$",
505 # 200 NEVER
507 "CLIENT_STORAGE_BIT\$",
508 "BUFFER_UPDATE_BARRIER_BIT\$",
509 "ACCUM_BUFFER_BIT\$",
511 "BUFFER_UPDATE_BARRIER_BIT_EXT\$",
515 # 400 FRONT_LEFT
517 "STENCIL_BUFFER_BIT\$",
518 "FRAMEBUFFER_BARRIER_BIT\$",
520 "FRAMEBUFFER_BARRIER_BIT_EXT\$",
523 # 800 EXP
525 "VIEWPORT_BIT\$",
526 "TRANSFORM_FEEDBACK_BARRIER_BIT\$",
528 "TRANSFORM_FEEDBACK_BARRIER_BIT_EXT\$",
532 # 1000 TEXTURE_WIDTH
534 "ATOMIC_COUNTER_BARRIER_BIT\$",
535 "TRANSFORM_BIT\$",
537 "ATOMIC_COUNTER_BARRIER_BIT_EXT\$",
541 # 2000 S
543 "SHADER_STORAGE_BARRIER_BIT\$",
544 "ENABLE_BIT\$",
546 # 4000 LIGHT0
548 "CLIENT_MAPPED_BUFFER_BARRIER_BIT\$",
549 "COLOR_BUFFER_BIT\$",
551 # 8000 ABGR_EXT
553 "HINT_BIT\$",
554 "QUERY_BUFFER_BARRIER_BIT\$",
556 # 10000 EVAL_BIT
558 "FONT_X_MIN_BOUNDS_BIT_NV\$",
559 "COLOR3_BIT_PGI\$",
561 # 20000 LIST_BIT
563 "FONT_Y_MIN_BOUNDS_BIT_NV\$",
564 "COLOR4_BIT_PGI\$",
566 # 40000 TEXTURE_BIT
568 "FONT_X_MAX_BOUNDS_BIT_NV\$",
569 "EDGEFLAG_BIT_PGI\$",
571 # 80000 SCISSOR_BIT
573 "FONT_Y_MAX_BOUNDS_BIT_NV\$",
574 "INDEX_BIT_PGI\$",
576 # 100000 FONT_UNITS_PER_EM_BIT_NV
578 "MAT_AMBIENT_BIT_PGI\$",
580 # 200000 FONT_ASCENDER_BIT_NV
582 "MAT_AMBIENT_AND_DIFFUSE_BIT_PGI\$",
584 # 400000 FONT_DESCENDER_BIT_NV
586 "MAT_DIFFUSE_BIT_PGI\$",
588 # 800000 FONT_HEIGHT_BIT_NV
590 "MAT_EMISSION_BIT_PGI\$",
592 # 1000000 FONT_MAX_ADVANCE_WIDTH_BIT_NV
594 "MAT_COLOR_INDEXES_BIT_PGI\$",
596 # 2000000 FONT_MAX_ADVANCE_HEIGHT_BIT_NV
598 "MAT_SHININESS_BIT_PGI\$",
600 # 4000000 FONT_UNDERLINE_POSITION_BIT_NV
602 "MAT_SPECULAR_BIT_PGI\$",
604 # 8000000 FONT_UNDERLINE_THICKNESS_BIT_NV
606 "NORMAL_BIT_PGI\$",
608 # 10000000 FONT_HAS_KERNING_BIT_NV
610 "TEXCOORD1_BIT_PGI\$",
612 # 20000000 MULTISAMPLE_BIT
614 "MULTISAMPLE_BIT_3DFX\$",
615 "TEXCOORD2_BIT_PGI\$",
617 # ffffffff ALL_ATTRIB_BITS
619 "INVALID_INDEX\$",
620 "ALL_SHADER_BITS\$",
621 "ALL_BARRIER_BITS\$",
622 "CLIENT_ALL_ATTRIB_BITS\$",
624 "ALL_BARRIER_BITS_EXT\$"
627 my @overload_ext =
629 "_ARB\$",
630 "_EXT\$",
631 "_NV\$",
632 "_ATI\$",
633 "_IBM\$",
634 "_HP\$",
635 "_SGI\$",
636 "_SGIS\$",
637 "_SGIX\$"
640 sub define_excluded
642 my $d = shift;
643 my $found = 0;
645 FOUND: foreach my $p (@exclude_list)
647 if($d =~ m/$p/)
649 $found = 1;
650 last FOUND;
654 if($found == 1)
656 # print "excluded : $d\n";
659 return $found;
662 sub define_one_way
664 my $d = shift;
665 my $found = 0;
667 FOUND: foreach my $p (@match_one_way_list)
669 if($d =~ m/$p/)
671 $found = 1;
672 last FOUND;
676 return $found;
679 sub process_define
681 my $d = shift;
682 my $v = shift;
684 if(define_excluded($d) == 1)
687 elsif(define_one_way($d) == 1)
689 if(exists $gl_define_list_one{$d})
691 # print "$d already there\n";
693 else
695 $gl_define_list_one{$d} = $v;
697 # push @gl_define_list_one, $d
699 else
701 if(exists $gl_define_list_two{$d})
703 # print "$d already there\n";
705 else
707 $gl_define_list_two{$d} = $v;
709 # push @gl_define_list_two, $d
713 sub processFile
715 my $f = shift;
717 open(IN, "grep #define $f |");
719 while(<IN>)
721 if($_ =~ m/(#define)[ \t]+(GL_[A-Z0-9_x]+)[ \t]+([0-9A-Fx]+)/)
723 process_define($2, $3);
725 elsif($_ =~ m/(#define)[ \t]+(GL_[A-Z0-9_x]+)[ \t]+(GL_[A-Z0-9_]+)/)
727 process_define($2, $3);
729 else
731 # print "Unknown $f $_";
735 close(IN);
738 processFile("/usr/include/GL.bugle/gl.h");
739 processFile("/usr/include/GL.bugle/glext.h");
741 #print "TWO WAY \n";
743 my @delete_from_two;
745 foreach my $define (keys %gl_define_list_two)
747 if($gl_define_list_two{$define} =~ m/^GL_/)
749 my $v = $gl_define_list_two{$define};
751 if(exists $gl_define_list_two{$v})
753 $gl_define_list_two{$define} = $gl_define_list_two{$v};
756 FINALEXT: foreach my $ext (@overload_ext)
758 if($define =~ m/$ext/)
760 my $d = $define;
761 $d =~ s/$ext//;
763 if(exists $gl_define_list_two{$d})
765 # print "$define | $d\n";
767 $gl_define_list_one{$define} = $gl_define_list_two{$define};
769 push @delete_from_two, $define
772 last FINALEXT;
775 # print "$define : $gl_define_list_two{$define}\n";
778 foreach my $key (@delete_from_two)
780 # print "del : $key\n";
782 delete($gl_define_list_two{$key});
785 my @k = (keys %gl_define_list_two);
787 #print "$#k\n";
789 #print "\nONE WAY \n";
791 @k = (keys %gl_define_list_one);
793 #print "$#k\n";
795 #foreach my $define (keys %gl_define_list_one)
797 # print "$define : $gl_define_list_one{$define}\n";
800 open(OUT, "> Source/Base/Base/OSGGLDefineMapper_auto.cpp");
802 print OUT "//#################################################\n";
803 print OUT "// auto generated use \n";
804 print OUT "// Tools/glEnumMapper/createGLEnumMaps.pl to rebuild\n";
805 print OUT "//#################################################\n\n\n";
807 print OUT "#include \"OSGGLDefineMapper.h\"\n\n\n";
808 print OUT "OSG_BEGIN_NAMESPACE\n\n";
810 my $nfuncs = 1;
811 my $defsperfunc = 100;
812 my $currentdef = $defsperfunc;
814 print OUT "#ifdef OSG_GL_DEFMAPPER\n\n";
815 print OUT "// Break up long function into pieces to relieve compiler optimizer\n\n";
816 print OUT "static void initMapsHelper_0(GLDefineMapperBase* mapper)\n";
817 print OUT "{\n";
820 foreach my $define (keys %gl_define_list_two)
822 if($currentdef == 0)
824 print OUT "}\n\n";
825 print OUT "static void initMapsHelper_$nfuncs(GLDefineMapperBase* mapper)\n";
826 print OUT "{\n";
827 $currentdef = $defsperfunc;
828 $nfuncs++;
830 $currentdef--;
832 my $d = $define;
834 $d =~ s/^GL_//;
836 print OUT " mapper->addToEnumPair (\"$d\", $gl_define_list_two{$define});\n";
837 print OUT " mapper->addFromEnumPair($gl_define_list_two{$define}, \"$d\");\n";
840 print OUT "\n\n";
842 foreach my $define (keys %gl_define_list_one)
844 if($currentdef == 0)
846 print OUT "}\n\n";
847 print OUT "static void initMapsHelper_$nfuncs(GLDefineMapperBase* mapper)\n";
848 print OUT "{\n";
849 $currentdef = $defsperfunc;
850 $nfuncs++;
852 $currentdef--;
854 my $d = $define;
856 $d =~ s/^GL_//;
858 print OUT " mapper->addToEnumPair (\"$d\", $gl_define_list_one{$define});\n";
861 print OUT "}\n\n";
862 print OUT "#endif\n\n";
865 print OUT "void GLDefineMapperBase::initMaps(void)\n";
866 print OUT "{\n";
867 print OUT "#ifdef OSG_GL_DEFMAPPER\n";
869 for (my $c = 0; $c < $nfuncs; $c++)
871 print OUT " initMapsHelper_$c(this);\n";
874 print OUT "#endif\n";
875 print OUT "}\n\n";
876 print OUT "OSG_END_NAMESPACE\n\n";
878 close(OUT);
880 exit;