Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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: # 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->{tex +t}); glEnable(&GL_LIGHTING); } }

In reply to Re: Adding text to PDL's TriD 3d graphs by bsb
in thread Adding text to PDL's TriD 3d graphs by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found