I'm using QML, and wanted to run custom OpenGL code. I created a custom Widget in C++ (extending QQuickItem) and overrided the paint function().
When I run my application, the console prints
QSGContext::initialize: depth buffer support missing, expect rendering errors
QSGContext::initialize: stencil buffer support missing, expect rendering errors
And just as it predicted, I do get rendering errors. I'll use a spider model as an example. Here's what it should like
I also don't know exactly how to describe it, but basically the opposite face (which should be blocked by the front face) is showing through as I rotate it.
I've managed to get rid of the depth buffer error with this:
void MyGLWidget::handleWindowChanged(QQuickWindow *win)
{
if (win) {
connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
connect(win, SIGNAL(sceneGraphInvalidated()), this, SLOT(cleanup()), Qt::DirectConnection);
win->setClearBeforeRendering(false);
QSurfaceFormat glFormat;
glFormat.setVersion(3,2);
glFormat.setProfile(QSurfaceFormat::CoreProfile);
/*I'm showing everything for context, but this is the key line*/
glFormat.setDepthBufferSize(1);
win->setFormat(glFormat);
}
}
So now I'm only getting the stencil error, but that causes a different issue. One side is completely black, and doesn't show any of the lighting.
Some other background info: I'm displaying a QQuickView. My OpenGLWidget is imported into QML and embedded like so:
MyGLWidget {
id: glWidget
}
In the paint() of my renderer, I am calling glEnable(GL_DEPTH_TEST) and glEnable(GL_STENCIL_TEST) at the top, but that doesn't seem to do anything. Maybe I'm calling that in the wrong context? I don't know where else I would be able to call it, however.


