QOpenGlWidget's ::paintEngine being called from QCoreApplication::processEvents
-
Hi and welcome to devnet,
Can you share your widget's code ?
-
Sure...here are the relevant QOpenGlWidget methods. I purposely have over-simplified them for now.
Unfortunately, none of these methods are involved in code path being called. :-(.
void
UiEventSourceWidget::initializeGL()
{
// Set up the rendering context, load shaders and other resources, etc.:
initializeOpenGLFunctions();
bool result;
uint error;error = glGetError();
Log4(L"UiEventSourceWidget::initializeGL:%d glGetError %d", LINE, error);
Assert(error == GL_NO_ERROR);glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
error = glGetError();
Log4(L"UiEventSourceWidget::initializeGL:%d glGetError %d", LINE, error);
Assert(error == GL_NO_ERROR);Log4(L"UiEventSourceWidget::initializeGL:%d context 0x%x, defaultFramebufferObject 0x%x",
LINE, context(), defaultFramebufferObject());
}void
UiEventSourceWidget::resizeGL(int w, int h)
{
Log4(L"UiEventSourceWidget::resizeGL");
update();
}void
UiEventSourceWidget::paintGL()
{
Log4(L"UiEventSourceWidget::paintGL QOpenGLContext::currentContext() 0x%x, "
"defaultFramebufferObject() %d, isValid %s, glGetError() %d",
QOpenGLContext::currentContext(),
defaultFramebufferObject(),
isValid() ? L"True" : L"False",
glGetError());uint error; error = glGetError(); Assert(error == GL_NO_ERROR); glClear(GL_COLOR_BUFFER_BIT); error = glGetError(); Assert(error == GL_NO_ERROR); glClear(GL_COLOR_BUFFER_BIT); error = glGetError(); Log4(L"UiEventSourceWidget::paintGL:%d glGetError %d", __LINE__, error); Assert(error == GL_NO_ERROR); windowPainter_->updateEntireWindow(); error = glGetError(); Log4(L"UiEventSourceWidget::paintGL:%d glGetError %d", __LINE__, error); Assert(error == GL_NO_ERROR); Log4(L"UiEventSourceWidget::paintGL ...exit");
}
-
FWIW, in QOpenGLWidget::paintEngine(), d->inBackingStorePaint is True.
-
By the way, what version of macOS are you running this on ?
-
10.14 (Mojave) but it also failed under High Sierra.
-
What is
windowPainter_
? -
It's the code that does our Rendering.
-
Would it be possible to also see that ?
-
Well, considering that it's rendering an entire Virtual World (There.com) I'm pretty sure it wouldn't fit in one post :-).
But, I can replace it with this and get the same problem.
glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); AssertNoGlError(); GLint drawFboId = 0, readFboId = 0, drawBoId = 0; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId); glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId); glGetIntegerv(GL_DRAW_BUFFER, &drawBoId); Log4(L"PoWglPlatform::openPlatform:%d, drawFboId %d, readFboId %d, drawBoId %d", __LINE__, drawFboId, readFboId, drawBoId); AssertNoGlError(); glColor3d(0.0,1.0,0.0); // Draw something static to the back buffer. glBegin(GL_QUADS); glVertex2d(0.0,0.0);glVertex2d(0.10,0.0);glVertex2d(0.10,0.10);glVertex2d(0.0,0.10); glEnd(); glFlush(); // If this line is uncommented, it proves that // glDrawBuffer(GL_FRONT) is not working!!!!!!!!!!!! //glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); //glDrawBuffer(GL_FRONT); float angle=0; for( angle=0;angle<360.0;angle+=2.0) { // This should restore our static drawing. glFlush(); float x=sin(angle*M_PI/180.0); float y=cos(angle*M_PI/180.0); glColor3d(1.0,1.0,1.0); glBegin(GL_LINES); glVertex2d(0.0,0.0); glVertex2d(x,y); glEnd(); glFinish(); } AssertNoGlError();
Also, here's ::initializeGL
// Set up the rendering context, load shaders and other resources, etc.:
initializeOpenGLFunctions();AssertNoGlError();
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
FWIW, the screen stays blue ( glClearColor(0.0f, 0.0f, 1.0f, 1.0f); ), and never turns red or draws anything we see in ::paintGL.
-
Using the minimal example above, I fixed this by removing this call in our QOpenGlWidget subclass's constructor:
setAttribute( Qt::WA_PaintOnScreen, true );
Removing this got rid of the paintengine calls (and numerous other problems).
Thanks!!!!