QOpenglWindow PaintGL() Native gl calls cause painter to disappear SOLVED
I've subclassed a QOpenglWindow, connected its update slot to its frameSwapped signal, and it merrily animates along.
I'm able to use Qpainter on the window to render some nice animated text, with glClear wiping the buffer each frame.
However, when I add some more fancy gl calls, the painter stuff gets wiped out. Remove the other gl calls, it's back. I've tried painting before and after the gl calls, wrapping them in beginNativePanting() and endNativePainting(), to no avail. Does anybody have any ideas?
Here's my paintGL function, minus some non-drawing animation stuff:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //painter.beginNativePainting(); m_program->bind(); QMatrix4x4 matrix; matrix.setToIdentity(); matrix.perspective(60, 4.0/3.0, 0.1, 100.0); matrix.lookAt(QVector3D(0.0,8.0,-20.0),QVector3D(0,0,0),QVector3D(0,1,0)); m_program->setUniformValue(m_matrixUniform, matrix);
if(validbuffer && pb1size > 0)
glVertexAttribPointer(m_posAttr,3 , GL_FLOAT, GL_FALSE, 0, 0);
glPointSize(4); glDrawArrays(GL_POINTS, 0, pb1size); } glDisableVertexAttribArray(m_posAttr); m_program->release();
painter.drawText(10,120, QString::number(m_Engine->GetFrameNum()) );
FIxed it by declaring
after releasing the program.