void *QGLContext::chooseVisual() { static int bufDepths[] = { 8, 4, 2, 1 }; // Try 16, 12 also? //todo: if pixmap, also make sure that vi->depth == pixmap->depth void* vis = 0; int i = 0; bool fail = FALSE; QGLFormat fmt = format(); bool tryDouble = !fmt.doubleBuffer(); // Some GL impl's only have double bool triedDouble = FALSE; while( !fail && !( vis = tryVisual( fmt, bufDepths[i] ) ) ) { if ( !fmt.rgba() && bufDepths[i] > 1 ) { i++; continue; } if ( tryDouble ) { fmt.setDoubleBuffer( TRUE ); tryDouble = FALSE; triedDouble = TRUE; continue; } else if ( triedDouble ) { fmt.setDoubleBuffer( FALSE ); triedDouble = FALSE; } if ( fmt.stereo() ) { fmt.setStereo( FALSE ); continue; } if ( fmt.accum() ) { fmt.setAccum( FALSE ); continue; } if ( fmt.stencil() ) { fmt.setStencil( FALSE ); continue; } if ( fmt.alpha() ) { fmt.setAlpha( FALSE ); continue; } if ( fmt.depth() ) { fmt.setDepth( FALSE ); continue; } if ( fmt.doubleBuffer() ) { fmt.setDoubleBuffer( FALSE ); continue; } fail = TRUE; } glFormat = fmt; return vis; }
/* See qgl.cpp for qdoc comment. */ void *QGLContext::chooseVisual() { Q_D(QGLContext); static const int bufDepths[] = { 8, 4, 2, 1 }; // Try 16, 12 also? //todo: if pixmap, also make sure that vi->depth == pixmap->depth void* vis = 0; int i = 0; bool fail = false; QGLFormat fmt = format(); bool tryDouble = !fmt.doubleBuffer(); // Some GL impl's only have double bool triedDouble = false; bool triedSample = false; if (fmt.sampleBuffers()) fmt.setSampleBuffers(QGLExtensions::glExtensions & QGLExtensions::SampleBuffers); while(!fail && !(vis = tryVisual(fmt, bufDepths[i]))) { if (!fmt.rgba() && bufDepths[i] > 1) { i++; continue; } if (tryDouble) { fmt.setDoubleBuffer(true); tryDouble = false; triedDouble = true; continue; } else if (triedDouble) { fmt.setDoubleBuffer(false); triedDouble = false; } if (!triedSample && fmt.sampleBuffers()) { fmt.setSampleBuffers(false); triedSample = true; continue; } if (fmt.stereo()) { fmt.setStereo(false); continue; } if (fmt.accum()) { fmt.setAccum(false); continue; } if (fmt.stencil()) { fmt.setStencil(false); continue; } if (fmt.alpha()) { fmt.setAlpha(false); continue; } if (fmt.depth()) { fmt.setDepth(false); continue; } if (fmt.doubleBuffer()) { fmt.setDoubleBuffer(false); continue; } fail = true; } d->glFormat = fmt; return vis; }