The problem I face is really simple : I'd like to implement some code to capture an OpenGl display on the screen to an image file.

It should be something like

Qt Code:
  1. Step 1 : NbBytes = size.width() * size.height() * screen_pixel_format/8;
  2. Step 2 : uchar *pPixelData = new uchar[NbBytes];
  3. Step 3 : glReadPixels(0,0,size.width(),size.height(),GL_BGR_EXT,GL_UNSIGNED_BYTE,pPixelData);
  4. Step 4 : QImage Image(pPixelData, size.width(),size.height(), NbBytes/ size.height(), QImage::Format_RGB888);
  5. Step 5 : Image.save(FileName);
To copy to clipboard, switch view to plain text mode 

Step 0 would be to find out what is the screen's pixel format, and which pixel format OpenGl is using : 8, 16, or 24 bits ? Is there way to get this information in Qt ?

Thanks