[vtk-developers] vtkXOpenGLTextMapper bug: an update.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Mon Oct 22 05:44:05 EDT 2001


hi,

After some more debugging on the problem reported by me in 

http://public.kitware.com/pipermail/vtk-developers/2001-October/000871.html

and

http://public.kitware.com/pipermail/vtk-developers/2001-October/000878.html

and 

http://public.kitware.com/pipermail/vtk-developers/2001-October/000874.html


I found that the problem occurs because, when you delete the
renderwindow, the textmapper still has CurrentFont set to the same old
font.  I guess that glXUseXFont segfaults when it is invoked with the
old CurrentFont (I have no idea why though).  The CurrentFont data
member is set in:

 void vtkXTextMapper::DetermineSize(vtkViewport *viewport, int *size)

This is in turn called from 

 void vtkXTextMapper::GetSize(vtkViewport* viewport, int *s)

which is called when vtkXOpenGLTextMapper::RenderGeometry is called.

When one deletes the old renderwindow and creates a new RenderWindow
to which the same actor is added, the GetSize method does *not* redo
DetermineSize.  This is because the TextMapper itself is unchanged.
So one possible fix would be to do a this->Modified() at the end of
the

void vtkXOpenGLTextMapper::ReleaseGraphicsResources(vtkWindow *win)

method.  This would force DetermineSize to be called again.  Would
appreciate if someone could let me know if this makes sense and let me
know if it is OK to add the following to

void vtkXOpenGLTextMapper::ReleaseGraphicsResources
<...>
  this->LastWindow = NULL;
  // Added line
  this->Modified()
}

I can test it and commit it but don't want to do it since I really am
not sure that this is the best solution.

Let me summarize:

 (1) glXUseXFont seems to crash when CurrentFont points to an already
 used font.  This is a guess made after going through the debugger.

 (2) vtkXTextMapper::CurrentFont is set in
 vtkXTextMapper::DetermineSize.  This is called from
 vtkXTextMapper::GetSize and is called only when 

 if (this->SizeMTime < this->MTime || 
     this->SizeMTime <this->FontMTime||		
      vSize[0] != this->ViewportSize[0] || 
      vSize[1] != this->ViewportSize[1])

 evaluates to true.

 (3) vtkXOpenGLTextMapper::ReleaseGraphicsResources does not 'Modify'
 itself hence when a new renderwindow is created, the
 CurrentFont is *not* reset.

Possible solution:

 Add a this->Modified() to vtkXOpenGLTextMapper::ReleaseGraphicsResources


What you have to tell me:

 Does the above make sense?  Is the above the "best" way to do it?  Or
 is there some other way?


thanks,
prabhu

-- 
http://www.aero.iitm.ernet.in/~prabhu      http://mayavi.sf.net

Virtue is a relative term.
		-- Spock, "Friday's Child", stardate 3499.1



More information about the vtk-developers mailing list