Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Adding text to PDL's TriD 3d graphs

by bsb (Priest)
on Mar 02, 2007 at 06:28 UTC ( #602830=note: print w/replies, xml ) Need Help??

in reply to Adding text to PDL's TriD 3d graphs

Thanks for this example, I found it very useful.

I thought I may be worth mentioning the extra element required to get 2-D position text, search for "Cargo-cult" below:

{ 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: # 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->{tex +t}); glEnable(&GL_LIGHTING); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://602830]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2017-01-18 05:18 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (160 votes). Check out past polls.