QGLWidget::renderText() generates multiple strings on the screen on different heights.

  • I'm using QGLWidget (together with libQGLViewer at the moment for convenience) to create a grid and show the camera distances.

    On the grid, there are quads drawn with the distance to the camera inside as text.
    For this I'm using QGLWidget::renderText(double x, double y, double z, ...)

    Now, the text seems to be render several times, on different heights. More like a ghosting effect.
    (I have a picture showing this behavior, but no server to put it on. Perhaps a nice addition for the QT forum ?!?)

           qglviewer::Vec cam = parent->camera()->position();
           qglviewer::Vec vec = qglviewer::Vec((minx+maxx)/2, (miny+maxy)/2, MAP_HEAT_SHOW_HEIGHT_TEXT);
           qreal dist = sqrt(POW(vec.x - cam.x) + POW(vec.y - cam.y) + POW(vec.z - cam.z));
           QFont font = QFont();
           if(dist < 30) {
           } else if(dist < 48) {
                  int fsize = 10;
                  fsize -= (fsize * (dist-30) )/20;
           if(dist < 48) {
                  glColor4f(0.0, 0.0, 0.0 ,(float)MAP_HEAT_ALPHA);
                  parent->renderText(vec.x, vec.y, vec.z, QString("%1").arg(dist), font);

Log in to reply