PageRenderTime 20ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/gl_const.pl

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