[vtk-developers] [ARB?] Plans for the vtkGL2PSExporter class.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Sun Jun 1 02:57:00 EDT 2003


>>>>> "SB" == Sebastien BARRE <sebastien.barre at kitware.com> writes:

    SB> At 5/31/2003 02:14 PM, Prabhu Ramachandran wrote:
    >> No, what i need is to know the current rendering location, the
    >> text to be output, its font and size.

    SB> Well then you just need the text mapper or text actor input
    SB> (i.e. text), the actor's location, then query the font
    SB> property (vtkTextProperty) for the font and size.

Indeed.  Read on for more information.

    >> So my thought was to somehow ask the TextMapper to make this
    >> call when gl2ps was doing its thing.

    SB> I do not know about gl2ps, what do you mean by "doing its
    SB> thing", what's the big picture here ? Where is gl2ps, between
    SB> VTK and the OpenGL lib ?

Well, here is how gl2ps works (quoted from the gl2ps docs -- I am no
GL2PS/OpenGL Guru myself):

  GL2PS works by capturing the contents of the OpenGL feedback buffer
  (see the description of glFeedbackBuffer and
  glRenderMode(GL_FEEDBACK) in the OpenGL documentation).

So AFAIK, all I have to do is setup gl2ps before I call
RenderWindow->Render().  Here is the relevant segment of code from the
vtkGL2PSExporter.cxx:

  while(state == GL2PS_OVERFLOW)
    {
    buffsize += 1024*1024;
    gl2psBeginPage(this->RenderWindow->GetWindowName(), "VTK", viewport,
                   format, GL2PS_BSP_SORT, options,
                   GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fpObj, fName);
    this->RenderWindow->Render();
    state = gl2psEndPage();
    }


Thats it (and it does work!).  The only trouble is text support does
not work.  gl2ps has a function called gl2psText to render text.  

  GLint gl2psText( const char *string, const char *fontname,
                   GLint fontsize );

When called while the RenderWindow is rendering this will produce text
output in the PostScript output or even write the text to a TeX file.

The troublesome part is that I need to identify all the TextMappers
that are rendered and when GL2PS is doing "its thing" (as described
above) I need to make calls to gl2psText.  I thought one simple way of
doing this would be to set a global flag on the text mappers like so:

 vtkTextMapper::GlobalGL2PSOn();

When this is turned on gl2psText function calls are made (inside the
text mappers) when the mapper is rendering its text.  As soon as gl2ps
is finished one can turn it off:

 vtkTextMapper::GlobalGL2PSOff();

Or something like that.  Alternatively, I would need to find all
active actors in the renderwindow, check if they are text actors, then
call gl2psText appropriately.  I am not sure which is the best
approach.  I thought that the Global flag was simpler to do.  Finding
all active actors and searching for text actors is a possiblility but
the code could be more complicated. OTOH if everyone starts using
global flags things can get messy.

I hope this is clear now.  I also appreciate any suggestions towards a
decent solution.

Thanks!

cheers,
prabhu



More information about the vtk-developers mailing list