Commit | Line | Data |
ee5feabd |
1 | #!/usr/bin/env perl |
2 | # |
3 | |
4 | open XS, "< opengl_words.txt"; |
5 | open CPP, "| cpp - > OpenGL.cx"; |
6 | |
7 | print CPP <<HEADER; |
8 | #include <GL/gl.h> |
9 | #include <GL/glu.h> |
10 | |
11 | --cut-- |
12 | HEADER |
13 | |
14 | while (<XS>) { |
15 | chomp(); |
16 | print CPP "#$_ $_\n"; |
17 | $words{$_} = 0; |
18 | } |
19 | |
20 | close XS; |
21 | close CPP; |
22 | |
23 | my $text; |
24 | open FP, "< OpenGL.cx" |
25 | or die "Couldn't open OpenGL.cx\n"; |
26 | { |
27 | local $/ = undef; |
28 | $text = <FP>; |
29 | } |
30 | |
31 | my ($junk,$goodstuff) = split "--cut--", $text; |
32 | |
33 | $goodstuff =~ s/#(GL[U]?_[A-Z0-9_]+)\s+([0-9xa-fA-F]+)/sub main::$1 { $2 }/g; |
34 | |
35 | for (split "\n",$goodstuff) { |
36 | if (/sub main::(GL[U]?_[A-Z0-9_]+)/ ) { |
37 | push @words, $1; |
38 | } |
39 | } |
40 | |
41 | for ( @words ) { |
42 | $words{$_} = 1; |
43 | } |
44 | |
45 | for ( keys %words ) { |
46 | print STDERR "Failed to find word $_" unless ($words{$_}); |
47 | } |
48 | |
49 | open OGL, "> ../lib/SDL/OpenGL/Constants.pm"; |
50 | |
51 | $words = join(" ",@words); |
52 | |
53 | print OGL <<HERE; |
54 | # SDL::OpenGL::Constants |
55 | # |
56 | # This is an autogenerate file, don't bother editing. |
57 | # Names are read from a list in opengl_words.txt and written by gl_const.pl. |
58 | # |
59 | # Copyright (C) 2003 David J. Goehrig <dave\@sdlperl.org> |
60 | |
61 | package SDL::OpenGL::Constants; |
62 | |
63 | $goodstuff |
64 | |
65 | 1; |
66 | |
67 | HERE |
68 | |
69 | system("rm OpenGL.cx"); |