OpenGl Overlaid with QPainter



  • Dear All:

    I am using the new Qt5.4 and I need to do some overlaid of OpenGL draw with the normal QPainter draw. I have override the @paintEvent@ function and I have writting the following code:

    @QPainter painter;
    painter.begin(this);

    makeCurrent();
    paintGL();
    
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);
    glViewport(0, 0, this->width(), this->height());
    
    QPen pen;
    pen.setColor(Qt::white);
    painter.setPen(pen);
    painter.fillRect(QRectF(10.0, 10.0, 50, 50), Qt::red);
    //painter.drawText(QRectF(10.0, 10.0, 50, 50), Qt::AlignCenter, "Pepe");
    painter.end();@
    

    in the paintGL function I have:

    @ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (auto &scene : renderScenes_)
            scene->paint();@
    

    which is where I draw the OpenGl stuff. For some reason I don't arrive to see the fillRect except if I remove the @for (auto &scene : renderScenes_)
    scene->paint();@ part. I don't know why because I am just sending normal openGl commands there. Is there anything that I have to paid specal attention?

    All the best
    Ernesto


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.