title: Depth Buffer and Stencil Buffer Issues QML
body: <p>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(). 
  <br>When I run my application, the console prints </p>
  
  <pre><code>QSGContext::initialize: depth buffer support missing, expect rendering errors
  QSGContext::initialize: stencil buffer support missing, expect rendering errors
  </code></pre>
  
  <p>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</p>
  
  <p><a href="https://i.stack.imgur.com/VDWUF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VDWUF.png" alt="spider stl"></a></p>
  
  <p>And here's what I'm getting 
  <a href="https://i.stack.imgur.com/HRBfH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HRBfH.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>I've managed to get rid of the depth buffer error with this:</p>
  
  <pre><code>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-&gt;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-&gt;setFormat(glFormat);
  
      }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/cISS2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cISS2.png" alt="enter image description here"></a></p>
  
  <p>Some other background info: I'm displaying a QQuickView. My OpenGLWidget is imported into QML and embedded like so:</p>
  
  <pre><code>MyGLWidget {
      id: glWidget
  }
  </code></pre>
  
  <p>In the paint() of my renderer, I am calling <code>glEnable(GL_DEPTH_TEST)</code> and <code>glEnable(GL_STENCIL_TEST)</code> 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.</p>