Acme-MITHALDU-BleedingOpenGL
view release on metacpan or search on metacpan
utils/glext_procs.pl view on Meta::CPAN
$|++;
my $file = '../include/GL/glext.h';
die "Unable to read '$file'" if (!open(FILE,$file));
my $exts = '../glext_procs.h';
die "Unable to write to '$exts'" if (!open(EXTS,">$exts"));
binmode EXTS;
my $exts = '../glext_consts.h';
die "Unable to write to '$exts'" if (!open(CNST,">$exts"));
binmode CNST;
my $exts = '../glext_types.h';
die "Unable to write to '$exts'" if (!open(TYPE,">$exts"));
binmode TYPE;
my $exps = 'exports.txt';
die "Unable to read '$exps'" if (!open(EXPS,$exps));
my $exports = {};
foreach my $line (<EXPS>)
{
$line =~ s|[\r\n]+||g;
next if (!$line);
$exports->{$line}++;
}
close(EXPS);
# Header
my $header = qq
{#ifndef %s
#define %s
#ifdef __cplusplus
extern "C" \{
#endif
/*
** This file is derived from glext.h and is subject to the same license
** restrictions as that file.
**
};
print EXTS sprintf $header, ("__glext_procs_h_") x 2;
print CNST sprintf $header, ("__glext_consts_h_") x 2;
print TYPE sprintf $header, ("__glext_types_h_") x 2;
# License
while (<FILE>)
{
my $line = $_;
next if ($line !~ m|^\*\* Copyright \(c\) 20\d\d-20\d\d The Khronos Group Inc\.|);
print EXTS $line;
print CNST $line;
last;
}
# Handle extensions
while (<FILE>)
{
my $line = $_;
if ($line =~ m|^\#ifdef __cplusplus|)
{
print "Found end\n";
print EXTS $line;
print CNST $line;
print TYPE $line;
next;
}
elsif ($line =~ m|^\#ifndef GL_[^\s]+|)
{
my $next_line = <FILE>;
if ($next_line !~ m|^\#define (GL_[^\s]+) 1|)
{
( run in 0.953 second using v1.01-cache-2.11-cpan-39bf76dae61 )