title: Render QImage with OpenGL
body: <p>Related to my <a href="https://stackoverflow.com/questions/20126354/render-qimage-from-sooffscreenrenderer-in-qglwidget">other question</a>, I think the more central question would be, how you render a <code>QImage</code> with OpenGL?</p>
  
  <p>I think the code has to look something like this, but I'm not sure what else I need, besides maybe <code>convertToGLFormat(img)</code>.</p>
  
  <pre><code>glEnable(GL_TEXTURE_2D);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  glGenTextures(1, &amp;offscreenBufferTexture);
  glBindTexture(GL_TEXTURE_2D, offscreenBufferTexture);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgGL.width(),
           imgGL.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
           imgGL.bits());
  
  glBegin(GL_QUADS);
    glTexCoord2d(0,0); glVertex2d(0, 0);
    glTexCoord2d(1,0); glVertex2d(windowSize.width(), 0);
    glTexCoord2d(1,1); glVertex2d(windowSize.width(), windowSize.height());
    glTexCoord2d(0,1); glVertex2d(0, windowSize.height());
  glEnd();
  glDisable(GL_TEXTURE_2D);
  </code></pre>
  
  <p>Also, I thought quick and dirty you could use <code>glDrawPixels()</code> (although you shouldn't), like</p>
  
  <pre><code>glDrawPixels(imgGL.width(), imgGL.height(), GL_RGBA,
           GL_UNSIGNED_BYTE, imgGL.bits());
  </code></pre>
  
  <p>But either way I can't see the image, just a white square with the size of it. I'm missing something here.</p>