AGLPixelFormat QGLContextPrivate::tryFormat(const QGLFormat &format) { GLint attribs[40], cnt = 0; bool device_is_pixmap = (paintDevice->devType() == QInternal::Pixmap); attribs[cnt++] = AGL_RGBA; attribs[cnt++] = AGL_BUFFER_SIZE; attribs[cnt++] = device_is_pixmap ? static_cast<QPixmap *>(paintDevice)->depth() : 32; attribs[cnt++] = AGL_LEVEL; attribs[cnt++] = format.plane(); if (format.redBufferSize() != -1) { attribs[cnt++] = AGL_RED_SIZE; attribs[cnt++] = format.redBufferSize(); } if (format.greenBufferSize() != -1) { attribs[cnt++] = AGL_GREEN_SIZE; attribs[cnt++] = format.greenBufferSize(); } if (format.blueBufferSize() != -1) { attribs[cnt++] = AGL_BLUE_SIZE; attribs[cnt++] = format.blueBufferSize(); } if (device_is_pixmap) { attribs[cnt++] = AGL_PIXEL_SIZE; attribs[cnt++] = static_cast<QPixmap *>(paintDevice)->depth(); attribs[cnt++] = AGL_OFFSCREEN; if(!format.alpha()) { attribs[cnt++] = AGL_ALPHA_SIZE; attribs[cnt++] = 8; } } else { if(format.doubleBuffer()) attribs[cnt++] = AGL_DOUBLEBUFFER; } if(glFormat.stereo()) attribs[cnt++] = AGL_STEREO; if(format.alpha()) { attribs[cnt++] = AGL_ALPHA_SIZE; attribs[cnt++] = format.alphaBufferSize() == -1 ? 8 : format.alphaBufferSize(); } if(format.stencil()) { attribs[cnt++] = AGL_STENCIL_SIZE; attribs[cnt++] = format.stencilBufferSize() == -1 ? 8 : format.stencilBufferSize(); } if(format.depth()) { attribs[cnt++] = AGL_DEPTH_SIZE; attribs[cnt++] = format.depthBufferSize() == -1 ? 32 : format.depthBufferSize(); } if(format.accum()) { attribs[cnt++] = AGL_ACCUM_RED_SIZE; attribs[cnt++] = format.accumBufferSize() == -1 ? 1 : format.accumBufferSize(); attribs[cnt++] = AGL_ACCUM_BLUE_SIZE; attribs[cnt++] = format.accumBufferSize() == -1 ? 1 : format.accumBufferSize(); attribs[cnt++] = AGL_ACCUM_GREEN_SIZE; attribs[cnt++] = format.accumBufferSize() == -1 ? 1 : format.accumBufferSize(); attribs[cnt++] = AGL_ACCUM_ALPHA_SIZE; attribs[cnt++] = format.accumBufferSize() == -1 ? 1 : format.accumBufferSize(); } if(format.sampleBuffers()) { attribs[cnt++] = AGL_SAMPLE_BUFFERS_ARB; attribs[cnt++] = 1; attribs[cnt++] = AGL_SAMPLES_ARB; attribs[cnt++] = format.samples() == -1 ? 4 : format.samples(); } attribs[cnt] = AGL_NONE; Q_ASSERT(cnt < 40); return aglChoosePixelFormat(0, 0, attribs); }