Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGLWidget::renderText() generates multiple strings on the screen on different heights.
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
qglwidget
1 Posts 1 Posters 788 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vincent van der Locht
    wrote on last edited by Vincent van der Locht
    #1

    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 ?!?)

           glDisable(GL_DEPTH_TEST);
           glDisable(GL_LIGHTING);
    
           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) {
                  font.setPointSize(10);
           } else if(dist < 48) {
                  int fsize = 10;
                  fsize -= (fsize * (dist-30) )/20;
                  font.setPointSize(fsize);
           }
           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);
           }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved