Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    qglwidget
    1
    1
    655
    Loading More Posts
    • 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
      Vincent van der Locht last edited by Vincent van der Locht

      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 Reply Quote 0
      • First post
        Last post