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