[gl2ps] Setting text color

David Lonie david.lonie at kitware.com
Mon Jun 18 23:25:22 CEST 2012


Hi List,

I'm having an issue setting the text color for gl2ps. From reading the
source, the current raster color is used:

gl2ps.c, gl2psAddText():
  glGetFloatv(GL_CURRENT_RASTER_COLOR, prim->verts[0].rgba);

I've tried to set the raster color in my code, following the docs and
calling glColor before glRasterPos:

      glColor3dv(tprop->GetColor());
      glRasterPos3dv(textPos);
      gl2psTextOpt(string, fontname.c_str(), fontSize, align, angle);

The text shows up in the output, but is always black. Digging a little
deeper, it seems to be an issue with the GL implementation -- the
raster color isn't getting captured at all. For instance:

      glColor3d(1.0, 0.0, 1.0);
      glRasterPos3d(0.0, 0.0, 0.0);
      double rasterColor[3];
      glGetDoublev(GL_CURRENT_RASTER_COLOR, rasterColor);
      cout << "RasterColor: " << rasterColor[0] << " " << rasterColor[1]
           << " " << rasterColor[2] << endl;

outputs:

RasterColor: 0 0 0

So it looks like the implementation doesn't bother keeping track of
the raster state during feedback mode (as suggested by
http://www.groupsrv.com/computers/about128565.html ).

Is this a known or common issue? Is there another way to set the color
of the text? For now I can hack in an extra color arg to the gl2ps
text calls, but I hate making changes to upstream sources.

Dave