Hi, I'm using QGLContext to render a small viewport with some triangles and rectangles in it. I have problems when trying to read the alpha channel back out using glReadPixels. Can this have something to do with using QGLContext?

Please see below:

I initialize like so:

Qt Code:
  1. QGLContext * context = 0;
  2. QGLFormat format;
  3. context = new QGLContext(format, (QPaintDevice *)glPanel);
  4. context->create();
  5. context->makeCurrent();
  6. glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  7. glClearDepth(1.0f);
To copy to clipboard, switch view to plain text mode 

I draw like so:

Qt Code:
  1. context->makeCurrent();
  2. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  3. glEnable(GL_CULL_FACE);
  4. glMatrixMode(GL_MODELVIEW);
  5. glLoadIdentity();
  6. glEnable(GL_ALPHA_TEST);
  7. glAlphaFunc(GL_GREATER, 0.0);
  8.  
  9. for(int i = 0; i < numWidgets; i++)
  10. {
  11. if(Widget[i]->type == TriangleWidget)
  12. {
  13. Widget[i]->DrawTriangle(mode);
  14. }
  15. else
  16. {
  17. Widget[i]->DrawRectangle(mode);
  18. }
  19. }
  20.  
  21. glFlush();
  22.  
  23. if(context->format().doubleBuffer())
  24. context->swapBuffers();
To copy to clipboard, switch view to plain text mode 

I use glReadPixels like so:

Qt Code:
  1. unsigned char * LUT2D = new unsigned char[256 * 256 * 4];
  2. context->makeCurrent();
  3. glReadBuffer(GL_FRONT);
  4. glReadPixels(0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, LUT2D);
  5.  
  6. // debug
  7. FILE * fp = fopen("/tmp/LUT2D.txt", "w+");
  8. if(fp)
  9. {
  10. unsigned int * tmp = (unsigned int *)LUT2D;
  11. for(int h = 0; h < 256; h++)
  12. {
  13. for(int w = 0; w < 256; w++)
  14. {
  15. fprintf(fp, "0x%08X, ", tmp[w * h]);
  16. }
  17. fprintf(fp, "\n");
  18. }
  19. fclose(fp);
  20. }
  21. // debug
To copy to clipboard, switch view to plain text mode 

As you can see, I'm writing the buffer to a file to see what's in the alpha channel. It's 0xFF (or 1.0 or 255 depending on your preference) for every value.

Once again, is this some weirdness with using QGLContext?