1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 80_stolen-from-head_TriD.dpatch by Henning Glawe <glaweh@physik.fu-berlin.de>
4
## All lines beginning with `## DP:' are a description of the patch.
8
diff -urNad pdl-2.4.2/Graphics/Makefile.PL /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/Makefile.PL
9
--- pdl-2.4.2/Graphics/Makefile.PL 2004-12-27 18:29:51.000000000 +0100
10
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/Makefile.PL 2006-06-03 22:41:02.261045250 +0200
13
'', 'char glBegin(); glBegin();',
14
libs('-lGL'), $mmpre)) {
15
- $libs = '-lGLU -lGL';
16
+ $libs = libs('-lGLU -lGL');
17
} elsif (trylink ('libMesaGL',
18
'', 'char glBegin(); glBegin();',
19
libs('-lMesaGL'), $mmpre)) {
20
- $libs = '-lMesaGLU -lMesaGL';
21
+ $libs = libs('-lMesaGLU -lMesaGL');
22
} elsif (trylink ('libMesaGL with pthread',
23
'', 'char glBegin(); glBegin();',
24
libs('-lMesaGL -lpthread'), $mmpre)) {
25
- $libs = '-lMesaGLU -lMesaGL -lpthread';
26
+ $libs = libs('-lMesaGLU -lMesaGL -lpthread');
29
# Add -lm to libs (Seems to be needed on Linux and Solaris, and shouldn't hurt for others)
32
my $lpath = '-L/usr/X11R6/lib -L/usr/lib/mesa';
33
my $extra = '-lXext -lX11 -lm';
34
- return "$lpath $libs $extra";
35
+ return ${[ExtUtils::Liblist->ext("$lpath $libs $extra")]}[0];
37
diff -urNad pdl-2.4.2/Graphics/TriD/Makefile.PL /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/Makefile.PL
38
--- pdl-2.4.2/Graphics/TriD/Makefile.PL 2004-08-19 08:27:38.000000000 +0200
39
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/Makefile.PL 2006-06-03 22:39:19.794641500 +0200
41
) if defined $PDL::Config{OPENGL_LIBS};
43
my $lib = ""; # Gets the first lib found...
44
- my @patterns = qw( GL.a GL.so MesaGL.a MesaGL.so );
45
+ my @patterns = qw( GL.a GL.so GL.dll.a MesaGL.a MesaGL.so Mesa.dll.a );
48
foreach my $dir (@check_dirs) {
49
diff -urNad pdl-2.4.2/Graphics/TriD/OpenGL/opengl.pd /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/OpenGL/opengl.pd
50
--- pdl-2.4.2/Graphics/TriD/OpenGL/opengl.pd 2004-12-27 18:30:24.000000000 +0100
51
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/OpenGL/opengl.pd 2006-06-03 22:39:19.794641500 +0200
53
# undefined function calls in "demo 3d", you've probably come to the right
56
+##############################
57
+# Notes 6-March-2006 CED - preparing for 2.4.3
59
+# Fuck. This is even worse than I thought. The latest is that it stopped compiling
60
+# under recent (2005) Fedora releases. The problem is that gl.h (and other headers)
61
+# now contain #ifdefs that make it practically impossible to parse them before
62
+# compile time. So now we spend a great deal of time assembling all the precursor
63
+# .h's for each .h, so that they are preprocessed in context. That means we need
64
+# a fence in the source files we feed to the preprocessor, so that we don't detect and
65
+# declare definitions that are already included from other .h files, or that are irrelevant
66
+# to GL (e.g. printf()). The previous solution was to simply ignore all #includes but there
67
+# is now enough compile-time switching that we have to preprocess the whole batch.
69
# TO DO: ensure that at least a particular subset of functions are found,
70
# or else barf the compile.
80
+# This next seems to be important to keep some extraneous mesa debugging definitions
81
+# from being caught. Blech.
82
+push(@defines,"-DGL_MESA_program_debug=0");
86
# The '/usr/X11R6/include' path is where GL/glx.h etc are found
87
# on my OS-X 10.3 machine. It seems to me that the Makefile.PL's should
88
# have set the paths up by now, rather than having the logic in the *pd
90
my @subnames; # filled by sub getfuncs
95
- 'double' => 'DOUBLE',
100
- 'GLenum' => 'U_LONG',
102
- 'GLXFBConfig' => 'PTR',
103
- 'Display *' => 'PTR',
105
+ 'unsigned long' => 'T_U_LONG',
106
+ 'signed long' => 'T_LONG',
107
+ 'long' => 'T_LONG',
109
+ 'unsigned int' => 'T_U_INT',
110
+ 'signed int' => 'T_INT',
113
+ 'unsigned short'=> 'T_U_SHORT',
114
+ 'signed short' => 'T_SHORT',
115
+ 'short' => 'T_SHORT',
117
+ 'unsigned char'=> 'T_U_CHAR',
118
+ 'signed char' => 'T_CHAR',
119
+ 'char' => 'T_CHAR',
121
+ 'void' => 'T_VOID',
123
+ 'float' => 'T_FLOAT',
124
+ 'double' => 'T_DOUBLE',
126
+ 'XID' => 'T_U_LONG',
127
+ 'void *' => 'T_PTR',
128
+ 'GLXFBConfig' => 'T_PTR',
129
+ 'Display *' => 'T_PTR',
130
+ 'Bool' => 'T_U_CHAR',
135
+my @pre_includes = ();
137
+my @post_includes = ("stdio.h");
139
open(TYPEMAP,">typemap") or die "Can not write typemap\n";;
143
+print STDERR "\nPDL::Graphics::TriD::OpenGL : Detecting GL API from system headers...\n";
145
foreach my $file (@types){
148
- print STDERR "\n******PROCESSING FILE $file.....";
149
+ print STDERR "\nPDL::Graphics::TriD::OpenGL: PROCESSING FILE $file.....";
153
- glpath: foreach my $path (@path){
154
- if(-e "$path/GL/$file"){
155
- &getconsts("$path/GL/$file");
156
- @file = &cpp("$path/GL/$file");
162
- print STDERR "WARNING: could not find file $file in $0 (may be okay)\n";
164
- }elsif($file=~/^X/){
166
- xpath: foreach my $path (@path){
167
- if(-e "$path/X11/$file"){
168
- &getconsts("$path/X11/$file");
169
- @file = &cpp("$path/X11/$file");
172
- }elsif(-e "/usr/include/X11/$file"){
173
- &getconsts("/usr/include/X11/$file");
174
- @file = &cpp("/usr/include/X11/$file");
180
- die "ERROR: Could not find $file in @path";
182
+ glpath: foreach my $path (@path){
183
+ foreach my $subdir("GL/","X11/","") {
184
+ if(-e "$path/$subdir$file"){
185
+ &getconsts("$path/$subdir$file");
186
+ push(@gl_includes,"$subdir$file");
189
+ @file = &cpp("$path/$subdir$file",[@pre_includes,@gl_includes]);
190
+# print STDERR "Got back from cpp - file has ".(0+@file)." lines...\n";
193
+ # Hack to identify XID-equivalent types and add them to the TYPEMAP.
194
+ # This generates typemap lines of the form "Window\tXID", because some perl
195
+ # versions (e.g. 5.8.6) don't ship with typemap entries for the X types.
197
+ hack:for( @prefile,@file ) {
198
+ next hack unless(m/^\s*typedef\s+XID\s+(\w+)\;/);
200
+ $t{$k} = $t{'XID'};
201
+# print STDERR "TYPEMAP ENTRY FOR $file: $k->XID\n";
204
+ # Hack to identify simple GL types and add them to the TYPEMAP.
206
+ hack2: for( @prefile,@file ) {
207
+# print STDERR "\t-$_";
208
+ next hack2 unless( m/^\s*typedef\s(.*)\s(GL\w+)\s*\;\s*$/);
209
+# print STDERR "\t-$_";
210
+ my($ctype,$gltype) = ($1,$2);
211
+ map { s/^\s*//; s/\s*$//; s/\s+/ /g; } ($ctype,$gltype);
212
+# print "\nTypedef sorting: $gltype is a $ctype\n";
214
+ unless($t{$ctype}) {
215
+ print STDERR "(Probably harmless): Sorting typedefs, but my little mind is blown! (ctype was '$ctype')\n";
218
+ $t{$gltype} = $t{$ctype};
221
+ hack3: for( @prefile,@file ) {
222
+# print STDERR "\t-$_";
223
+ next hack3 unless( m/^\s*typedef\s.*\*(_*GL\w+).*\;\s*$/);
224
+# print STDERR "\t:$_";
225
+ my($gltype) = ($1);
226
+ map { s/^\s*//; s/\s*$//; s/\s+/ /g; } ($gltype);
227
+# print "\nTypedef sorting: $gltype is a ptr\n";
229
+ $t{$gltype} = "T_PTR";
239
+ print STDERR "WARNING: could not find file $file in path '".join(":",@path)."'. (may be okay)\n";
242
- print STDERR ":::::::::::::::::::::::::::::::::\n";
243
- print STDERR "Calling gettypes for $file ",$#file,"\n" if($verbose);
245
- print "GLXContext T_PTR\n";
246
- print "GLXFBConfigSGIX T_PTR\n";
249
+# print STDERR ":::::::::::::::::::::::::::::::::\n";
250
+# print STDERR "PDL::Graphics::TriD::OpenGL: Calling gettypes for $file (",$#file,")\n" ;
255
+print (STDERR "\n\n\n\n\n\n\n\n\n\n\n\n\n\n************************************\n***********************************\n*****************************\nPre-processed files. gl_includes is now ",join(",",@gl_includes),"...\n\n\n\n\n\n\n\n");
258
while ( my ($key, $val) = each %t ) {
259
- print "$key T_$val\n"
260
+ print TYPEMAP "$key $val\n" ;
271
+my @typemap_lines = map { "$_\t$t{$_}\n" } keys %t;
274
+join("\n",map {"#include <$_>"} (@pre_includes,@gl_includes,@post_includes)) .
279
@@ -169,13 +238,16 @@
280
return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
289
# generate the xs code
292
my $ppcode = "pp_addxs('','\n";
294
$ppcode .= glpcopenwindow();
295
$ppcode .= "\n');\n\n";
297
@@ -223,48 +295,117 @@
302
+ my ($file) = shift;
303
+ my ($include_list) = shift || [];
305
+ my @includes = map { "\n#include <$_>\n" } @$include_list;
307
+ my $open_fencestr = "11HdyTbIVg6s"; # some gibberish output by DES
308
+ my $close_fencestr = "23Cnba1nbf31"; # some gibberish I type
310
print STDERR "Running cpp on $file\n"if($verbose);
311
open(FILE,"$file") || die "Could not open file $file";
313
+ my @rawfile = (@includes, "Start of $file ($close_fencestr)....\n", <FILE>);
317
$nfile =~ s/.*\//tmp_/;
319
open(TFILE,">$nfile") || die "Could not write $nfile";
321
+ ##############################
322
+ # Walk through the file and mark the last instance of #include with a fence
327
+ my $line = shift @rawfile;
328
+ if($line =~ m/\s*\#include\s/) {
329
+ $line =~ s/\n(.)/\\n$1/g;
331
+ push(@file,"\nFENCE ($open_fencestr): Ignore stuff till the next fence ($line)\n\n");
332
+ push(@file,$line."\n");
333
+ push(@file,"\nFENCE ($close_fencestr): Stop ignoring stuff\n\n");
339
+ ##############################
340
+ # Now dump the processed array to a temp file for cpp to crunch on
342
-# print STDERR "from $file: ",$_ ;
343
- next if(/^\s*\#include\s+/); # this is dangerous
344
- # as a consequence APIENTRY is undefined and glu routines are ignored
345
+# print STDERR "from $file: ",$_ ;
351
# Put together a preprocessor command
354
my $com="$Config{cpprun} -P @defines";
355
- foreach(split ' ', $Config{cppflags}){
356
- $com .= " $_" if(/-D/);
357
+ foreach(split ' ', $Config{cppflags}.' '.$Config{cflags} . ' ' . $Config{ccflags}){
358
+ $com .= " $_" if(1 || /-D/);
360
$com .= " -D_LANGUAGE_C -DAPIENTRY=''"; # forces prototypes of SGI GL
362
print STDERR "*** CPP command: $com $nfile |\n";
364
- open(FILE,"$com $nfile |") || die "cant open $com $nfile|\n";
367
+ ##############################
368
+ # Execute cpp and snarf up its output
369
+ open(CPP_PIPE,"$com $nfile |") || die "cant open $com $nfile|\n";
370
+ @rawfile = <CPP_PIPE>;
373
+# print STDERR "CPP call returned ".(0+@rawfile)." lines...\n";
377
my $out = basename($file).".cpp";
379
die "can't open temp output file $out";
380
- print "outputting to $out...\n";
381
+# print STDERR "outputting to $out...\n";
382
print FI "/* command: $com */\n";
383
- print FI join('',@file);
384
+ print FI join('',@rawfile);
388
+ ##############################
389
+ # Edit out the sections to be ignored...
392
+ print STDERR "open_fencestr = '$open_fencestr'; close_fencestr = '$close_fencestr'\n";
393
+ print STDERR "rawfile has ".(0+@rawfile)." lines...\n";
395
+ for my $line(@rawfile) {
397
+ if($line =~ m/$open_fencestr/o) {
398
+# print "Starting to ignore - trigger line was '$line' (line $lineno)\n";
402
+ if($line =~ m/$close_fencestr/o) {
403
+# print "Ending ignorance - trigger line was '$line (line $lineno);'\n";
408
+ unless($ignoring) {
409
+ push (@file,"$line\n");
410
+# print STDERR "Keeping: $line\n";
413
+# print STDERR "*******: $line\n";
417
+ my $str = join("\n",@file);
418
+ @file = split /\n/,$str;
420
+ open(FILE,">${nfile}-out");
423
+ print STDERR "SUB CPP: Returning ".(0+@file)." lines...\n";
433
my $str = join ' ',@file;
436
# while($str =~ /extern\s+(\S[^\;]*)\s+(\w+)\s*\(([^\(\)]*)\)\s*\;/gs){
438
while($str =~ /(extern\s)?\s*(\w+)\s+(\w+)\s*\(([^\(\)]*)\)\s*\;/gs){
440
if($args =~ /GLvoid\s*\*\s*\*/) { next }
442
push @subnames,$name;
443
- print "Gen: $rt $name $args\n" if $verbose;
444
+# print "Gen: $rt $name $args\n" if $verbose;
445
# push @vfuncs,"$rt,$name,V_$name,($args)";
447
# Ignore Display * when looking for pointers
448
diff -urNad pdl-2.4.2/Graphics/TriD/Rout/rout.pd /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/Rout/rout.pd
449
--- pdl-2.4.2/Graphics/TriD/Rout/rout.pd 2002-06-01 05:31:58.000000000 +0200
450
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/Rout/rout.pd 2006-06-03 22:39:19.794641500 +0200
452
formchar,formchar,formchar);
455
- PerlIO_fprint(fp,formatstr,@.trid(vertices,n).');
456
+ PerlIO_printf(fp,formatstr,@.trid(vertices,n).');
460
diff -urNad pdl-2.4.2/Graphics/TriD/TriD/GL.pm /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/GL.pm
461
--- pdl-2.4.2/Graphics/TriD/TriD/GL.pm 2002-06-27 03:07:51.000000000 +0200
462
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/GL.pm 2006-06-03 22:39:19.798641750 +0200
466
my($this, $options) = @_;
468
+ print "GL gdriver...\n" if($PDL::debug_trid);
470
if(defined $this->{_GLObject}){
471
print "WARNING: Graphics Driver already defined for this window \n";
472
@@ -598,12 +600,17 @@
475
print "STARTING OPENGL $options->{width} $options->{height}\n" if($PDL::Graphics::TriD::verbose);
478
+ print "gdriver: Calling OpengGL::OO($options)...\n" if($PDL::debug_trid);
480
$this->{_GLObject}= new PDL::Graphics::OpenGL::OO($options);
482
#glpOpenWindow(%$options);
484
+ print "gdriver: Calling glClearColor...\n" if($PDL::debug_trid);
485
glClearColor(0,0,0,1);
487
+ print "gdriver: Calling glpRasterFont...\n" if($PDL::debug_trid);
488
my $lb = $this->{_GLObject}->glpRasterFont(
489
($ENV{PDL_3D_FONT} or "5x8"),0,256);
490
$PDL::Graphics::TriD::GL::fontbase = $lb;
491
diff -urNad pdl-2.4.2/Graphics/TriD/TriD/Objects.pm /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/Objects.pm
492
--- pdl-2.4.2/Graphics/TriD/TriD/Objects.pm 2000-08-08 13:18:48.000000000 +0200
493
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/Objects.pm 2006-06-03 22:39:19.798641750 +0200
497
my($type,$points,$colors,$options) = @_;
500
+ print "GObject new.. calling SUPER::new...\n" if($PDL::debug_trid);
501
my $this = $type->SUPER::new();
502
+ print "GObject new - back (SUPER::new returned $this)\n" if($PDL::debug_trid);
504
if(!defined $options and ref $colors eq "HASH") {
509
+ print "GObject new - calling realcoords\n" if($PDL::debug_trid);
510
$points = PDL::Graphics::TriD::realcoords($type->r_type,$points);
511
+ print "GObject new - back from realcoords\n" if($PDL::debug_trid);
513
if(!defined $colors) {$colors = PDL->pdl(1,1,1);
514
$colors = $type->cdummies($colors,$points);
516
$this->{Colors} = $colors;
518
$this->check_options();
520
+ print "GObject new - returning\n" if($PDL::debug_trid);
524
diff -urNad pdl-2.4.2/Graphics/TriD/TriD/Window.pm /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/Window.pm
525
--- pdl-2.4.2/Graphics/TriD/TriD/Window.pm 2000-10-09 12:01:00.000000000 +0200
526
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD/Window.pm 2006-06-03 22:39:19.798641750 +0200
529
my($arg,$options) = @_;
531
+ print "PDL::Graphics::TriD::Window - calling SUPER::new...\n" if($PDL::debug_trid);
532
my $this = $arg->SUPER::new();
534
+ print "PDL::Graphics::TriD::Window - got back $this\n" if($PDL::debug_trid);
535
# Make sure the Graphics has been initialized
536
$options->{width} = 300 unless defined $options->{width};
537
$options->{height} = 300 unless defined $options->{height};
538
$this->{Width} = $options->{width};
539
$this->{Height} = $options->{height};
541
+ print "PDL::Graphics::TriD::Window: calling gdriver....\n" if($PDL::debug_trid);
542
$this->{Interactive} = $this->gdriver($options);
543
+ print "PDL::Graphics::TriD::Window: gdriver gave back $this->{Interactive}....\n" if($PDL::debug_trid);
546
if($this->{Interactive}){
547
+ print "\tIt's interactive... calling ev_defaults...\n" if($PDL::debug_trid);
548
$this->{Ev} = $this->ev_defaults();
549
+ print "\tcalling new_viewport...\n" if($PDL::debug_trid);
550
$this->new_viewport(0,0,$this->{Width},$this->{Height});
552
$this->new_viewport(0,0,1,1);
555
$this->current_viewport(0);
559
print "AUTOLOAD: $sub at ",__FILE__," line ", __LINE__ ,".\n"
560
if($PDL::Graphics::TriD::verbose);
562
+ print "Window AUTOLOADing '$sub': self=$self, args='".join("','",@args),"'\n" if($PDL::debug_trid);
564
if($sub =~ /^gl/ && defined $self->{_GLObject}){
565
return $self->{_GLObject}->$sub(@args);
567
diff -urNad pdl-2.4.2/Graphics/TriD/TriD.pm /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD.pm
568
--- pdl-2.4.2/Graphics/TriD/TriD.pm 2000-08-25 22:24:09.000000000 +0200
569
+++ /tmp/dpep.IxNtli/pdl-2.4.2/Graphics/TriD/TriD.pm 2006-06-03 22:39:19.798641750 +0200
571
if(!defined $obj or !ref $obj) {
572
barf("Invalid object to TriD::graph_object");
574
+ print "graph_object: calling get_new_graph\n" if($PDL::debug_trid);
575
my $g = get_new_graph();
576
+ print "graph_object: back from get_new_graph\n" if($PDL::debug_trid);
578
my $name = $g->add_dataseries($obj);
579
$g->bind_default($name);
583
# Call: line3d([$x,$y,$z],[$color]);
584
*line3d=\&PDL::line3d;
585
-sub PDL::line3d { &checkargs;
586
- &graph_object(new PDL::Graphics::TriD::LineStrip(@_));
589
+ my $obj = new PDL::Graphics::TriD::LineStrip(@_);
590
+ print "line3d: object is $obj\n" if($PDL::debug_trid);
591
+ &graph_object($obj);
594
*contour3d=\&PDL::contour3d;
596
*release3d=\&PDL::release3d;
599
+ print "get_new_graph: calling PDL::Graphics::TriD::get_current_window...\n" if($PDL::debug_trid);
600
my $win = PDL::Graphics::TriD::get_current_window();
602
+ print "get_new_graph: calling get_current_graph...\n" if($PDL::debug_trid);
603
my $g = get_current_graph($win);
604
+ print "get_new_graph: back get_current_graph returned $g...\n" if($PDL::debug_trid);
606
if(!$PDL::Graphics::TriD::hold_on) {
609
if(!$PDL::Graphics::TriD::create_window_sub) {
610
barf("PDL::Graphics::TriD must be used with a display mechanism: for example PDL::Graphics::TriD::GL!\n");
612
+ print "get_current_window - creating window...\n" if($PDL::debug_trid);
613
$win = new PDL::Graphics::TriD::Window($opts);
615
+ print "get_current_window - calling set_material...\n" if($PDL::debug_trid);
616
$win->set_material(new PDL::Graphics::TriD::Material);
617
$PDL::Graphics::TriD::current_window = $win;
618
$PDL::Graphics::TriD::cur = $win