openglq.pd (PDL-2.076) | : | openglq.pd (PDL-2.077) | ||
---|---|---|---|---|
use strict; | use strict; | |||
use warnings; | use warnings; | |||
use PDL::Types qw(types ppdefs_all); | use PDL::Types qw(types ppdefs_all); | |||
my $F = [map $_->ppsym, grep $_->real && !$_->integer, types]; | my $F = ['F']; | |||
pp_addpm({At=>'Top'},<<'EOD'); | pp_addpm({At=>'Top'},<<'EOD'); | |||
=head1 NAME | =head1 NAME | |||
PDL::Graphics::OpenGLQ - quick routines to plot lots of stuff from ndarrays. | PDL::Graphics::OpenGLQ - quick routines to plot lots of stuff from ndarrays. | |||
=head1 SYNOPSIS | =head1 SYNOPSIS | |||
only for internal use - see source | only for internal use - see source | |||
skipping to change at line 42 | skipping to change at line 42 | |||
pp_addhdr(' | pp_addhdr(' | |||
#ifdef HAVE_AGL_GLUT | #ifdef HAVE_AGL_GLUT | |||
#include <OpenGL/gl.h> | #include <OpenGL/gl.h> | |||
#include <OpenGL/glu.h> | #include <OpenGL/glu.h> | |||
#else | #else | |||
#include <GL/gl.h> | #include <GL/gl.h> | |||
#include <GL/glu.h> | #include <GL/glu.h> | |||
#endif | #endif | |||
/* #include <GL/glx.h> */ | /* #include <GL/glx.h> */ | |||
/* #include "../OpenGL/OpenGL.m" */ | ||||
/* D_OPENGL; */ | ||||
'); | '); | |||
#pp_add_boot(' | my @internal = (Doc => 'internal', NoPthreading => 1); | |||
# I_OPENGL; | ||||
#'); | ||||
my @internal = (Doc => 'internal'); | ||||
pp_def( | pp_def( | |||
'line_3x_3c', | 'line_3x_3c', | |||
GenericTypes => $F, | GenericTypes => $F, | |||
Pars => 'coords(tri=3,n); colors(tri,n);', | Pars => 'coords(tri=3,n); colors(tri,n);', | |||
Code => ' | Code => ' | |||
glBegin(GL_LINE_STRIP); | glBegin(GL_LINE_STRIP); | |||
loop(n) %{ | loop(n) %{ | |||
glColor3f( | glColor3f( | |||
$colors(tri => 0), | $colors(tri => 0), | |||
skipping to change at line 76 | skipping to change at line 69 | |||
$coords(tri => 0), | $coords(tri => 0), | |||
$coords(tri => 1), | $coords(tri => 1), | |||
$coords(tri => 2) | $coords(tri => 2) | |||
); | ); | |||
%} | %} | |||
glEnd(); | glEnd(); | |||
', | ', | |||
@internal | @internal | |||
); | ); | |||
sub TRI {my $s = join '', @_; return "$s(tri => 0), | sub TRI { my $par = join '', @_; join ',', map "$par(tri => $_)", 0..2 } | |||
$s(tri => 1), | sub make_tri { shift."(".TRI(@_).");\n" } | |||
$s(tri => 2)"} | sub COLOR { make_tri("glColor3f",'$colors',@_) } | |||
sub COLOR{ " | sub VERTEX { make_tri("glVertex3f",'$coords',@_) } | |||
glColor3f( | sub NORMAL { make_tri("glNormal3f",'$norm',@_) } | |||
". TRI('$colors',@_) | sub RPOS { make_tri("glRasterPos3f",'$coords',@_) } | |||
." | sub ADCOLOR { " | |||
); | { | |||
" }; | GLfloat ad[] = { ".TRI('$colors'.$_[0]).",1.0 }; | |||
sub ADCOLOR{ " | glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE, ad); | |||
{ | } | |||
GLfloat ad[4]; | " } | |||
".(join '',map {"ad[$_] = \$colors$_[0](tri => $_);"} 0.. | ||||
2). | sub make_func { | |||
"ad[3] = 1.0; | my ($name) = @_; | |||
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE, | for (['_col', ' colors(tri,n);', COLOR().VERTEX()], ['_nc', '', VERTEX()]) { | |||
ad); | pp_def(lc($name).$_->[0], | |||
} | GenericTypes => $F, | |||
" }; | Pars => 'coords(tri=3,n);'.$_->[1], | |||
sub VERTEX{ " | Code => ' | |||
glVertex3f( | glBegin('.uc($name).'); | |||
". TRI('$coords',@_) | loop(n) %{'.$_->[2].'%} | |||
." | glEnd(); | |||
); | ', | |||
" }; | @internal | |||
sub NORMAL{ " | ); | |||
glNormal3f( | } | |||
". TRI('$norm',@_) | } | |||
." | ||||
); | ||||
" }; | ||||
sub RPOS{ " | ||||
glRasterPos3f( | ||||
". TRI('$coords',@_) | ||||
." | ||||
); | ||||
" }; | ||||
pp_def('gl_points', | ||||
GenericTypes => $F, | ||||
Pars => 'coords(tri=3); colors(tri);', | ||||
Code => ' | ||||
glBegin(GL_POINTS); | ||||
broadcastloop %{'.COLOR().VERTEX().' | ||||
%} | ||||
glEnd(); | ||||
', | ||||
@internal | ||||
); | ||||
pp_def( | ||||
'gl_lines', | ||||
GenericTypes => $F, | ||||
Pars => 'coords(tri,x);colors(tri,x);', | ||||
Code => ' | ||||
glBegin(GL_LINES); | ||||
loop(x) %{ '.COLOR().VERTEX().' | ||||
%} | ||||
glEnd(); | ||||
', | ||||
@internal | ||||
); | ||||
pp_def( | make_func($_) for qw(gl_line_strip gl_lines gl_points); | |||
'gl_line_strip', | ||||
GenericTypes => $F, | ||||
Pars => 'coords(tri,x);colors(tri,x);', | ||||
Code => ' | ||||
glBegin(GL_LINE_STRIP); | ||||
loop(x) %{ '.COLOR().VERTEX().' | ||||
%} | ||||
glEnd(); | ||||
', | ||||
@internal | ||||
); | ||||
pp_def( | pp_def( | |||
'gl_texts', | 'gl_texts', | |||
GenericTypes => $F, | GenericTypes => $F, | |||
Pars => 'coords(tri,x); ', | Pars => 'coords(tri,x); ', | |||
OtherPars => 'int base; SV *arr', | OtherPars => 'int base; SV *arr', | |||
Code => ' | Code => ' | |||
SV *sv = $COMP(arr); | SV *sv = $COMP(arr); | |||
AV *arr; | AV *arr; | |||
if(!(SvROK(sv) && SvTYPE(SvRV(sv))==SVt_PVAV)) { | if(!(SvROK(sv) && SvTYPE(SvRV(sv))==SVt_PVAV)) { | |||
End of changes. 5 change blocks. | ||||
83 lines changed or deleted | 31 lines changed or added |