2
votes

I have the following code

void QMyWidget::paintEvent(QPaintEvent *event)
{

    updateGL(); // This calls for initializeGL and then paintGL and draws a nice openGL 3D scene


    QPainter painter(this); 
    // Draw something with QPainter..
}

the problem is that the QPainter line calls several times initializeGL and paintGL and eventually creates a BLANK/GRAY area over my OpenGL rendered scene.. if I try to draw something like a drawText with the QPainter, the text is shown but the background of the text is a gray rect that covers ENTIRELY my OpenGL drawn scene.

What's wrong with this?

1
And what happens if you call "updateGL();" after "QPainter painter(this);"? - Goz
There's a flickering and I can see my 3D scene rendered, then the entire scene goes white and the content of QPainter is rendered instead of the 3D scene - Johnny Pauling
To provide additional information: if I use QPainter painter; (with no device selected) everything's okay. It seems that QPainter painter(this); clears the rendered framebuffer before working on it - Johnny Pauling
I'm afraid there's some VBO/VAO not unbinded or unbinded too many times (and messed up), can someone provide me how to unbind VBO and VAOs? - Johnny Pauling

1 Answers

1
votes

Solved: multi-pass rendering was deactivated so the scene was being rendered multiple times