[vtk-developers] vtkTextActor (and vtkTextures?) with gradient backgrounds

Jeff Baumes jeff.baumes at kitware.com
Tue Oct 27 08:11:39 EDT 2009


On Mon, Oct 26, 2009 at 10:19 PM, David Feng <dfeng at cs.unc.edu> wrote:

> It looks vtkTextActor doesn't play well with gradient backgrounds.  The
> background disappears entirely when I add a vtkTextActor to my renderer,
> which is embedded in a vtkRenderView.  I suspect it's because vtkTextActor
> uses a vtkTexture, which enables GL_ALPHA_TEST (in the OpenGL version).  The
> background is rendered as a 0.0 alpha colored quad (when gradient
> backgrounds are enabled), and the alpha function is discarding all 0.0 alpha
> fragments for the following reason:
>
>  // don't accept fragments if they have zero opacity. this will stop the
>  // zbuffer from be blocked by totally transparent texture fragments.
>  glAlphaFunc (GL_GREATER, static_cast<GLclampf>(0));
>  glEnable (GL_ALPHA_TEST);
>
> Simply adding glDisable(GL_ALPHA_TEST) to the PostRender method didn't seem
> to affect my output, so my diagnosis could be wrong.  If it is something
> along these lines, I'm seems like all vtkTextures will clobber gradient
> backgrounds.
>
> Regardless, it looks like vtkTextMapper doesn't cause these problems, so
> I'll be switch to that for now.  Does anyone know of a simple way to have
> the vtkTextMapper scale with viewport size?
>
>
The issue we have run into several times with the gradient background is
that mappers/actors in VTK do not always reset their state after rendering.
It is not textures in general since I've used textures with a gradient
background before (e.g. in vtkGeoView).

I believe the text mapper draws pixels directly on the screen, so they are
always constant size. The text actor renders a texture to a quad in the
scene, which is why it can scale.

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20091027/10113a4a/attachment.html>


More information about the vtk-developers mailing list