{ package Text; BEGIN{ @Text::ISA = qw/PDL::Graphics::TriD::Object/;} use PDL::Graphics::OpenGLQ; use PDL::Graphics::OpenGL; sub new { my ($class, $text, $x, $y) = @_; my $lb = PDL::Graphics::TriD::get_current_window ->glpRasterFont("8x13",0,255); bless { lb => $lb, text => $text, posn => [$x,$y,0] }, $class; } sub togl { my $self = shift; # Cargo-cult: # http://glprogramming.com/red/chapter08.html glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, 1.0, 0.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(&GL_LIGHTING); glColor3f(1,1,1); my @posn = @{ $self->{posn} }; glRasterPos3f($posn[0], $posn[1], $posn[2]); PDL::Graphics::OpenGL::glpPrintString($self->{lb}, $self->{text}); glEnable(&GL_LIGHTING); } }