Ejemplo n.º 1
0
/*!
    \since 4.8

    Returns a platform window format for the OpenGL format specified by \a format.
*/
QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
{
    QPlatformWindowFormat retFormat;
    retFormat.setAccum(format.accum());
    if (format.accumBufferSize() >= 0)
        retFormat.setAccumBufferSize(format.accumBufferSize());
    retFormat.setAlpha(format.alpha());
    if (format.alphaBufferSize() >= 0)
        retFormat.setAlphaBufferSize(format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    retFormat.setDepth(format.depth());
    if (format.depthBufferSize() >= 0)
        retFormat.setDepthBufferSize(format.depthBufferSize());
    retFormat.setDirectRendering(format.directRendering());
    retFormat.setDoubleBuffer(format.doubleBuffer());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    retFormat.setRgba(format.rgba());
    retFormat.setSampleBuffers(format.sampleBuffers());
    if (format.samples() >= 0)
        retFormat.setSamples(format.samples());
    retFormat.setStencil(format.stencil());
    if (format.stencilBufferSize() >= 0)
        retFormat.setStencilBufferSize(format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    retFormat.setSwapInterval(format.swapInterval());
    return retFormat;
}
Ejemplo n.º 2
0
static void qt_format_to_attrib_list(const QGLFormat &f, int attribs[])
{
    int i = 0;
    attribs[i++] = GLX_RENDER_TYPE;
    attribs[i++] = GLX_RGBA_BIT;
    attribs[i++] = GLX_DRAWABLE_TYPE;
    attribs[i++] = GLX_PBUFFER_BIT;
    attribs[i++] = GLX_RED_SIZE;
    attribs[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize();
    attribs[i++] = GLX_GREEN_SIZE;
    attribs[i++] = f.greenBufferSize() == -1 ? 1 : f.greenBufferSize();
    attribs[i++] = GLX_BLUE_SIZE;
    attribs[i++] = f.blueBufferSize() == -1 ? 1 : f.blueBufferSize();
    if (f.doubleBuffer()) {
        attribs[i++] = GLX_DOUBLEBUFFER;
        attribs[i++] = true;
    }
    if (f.depth()) {
        attribs[i++] = GLX_DEPTH_SIZE;
        attribs[i++] = f.depthBufferSize() == -1 ? 1 : f.depthBufferSize();
    }
    if (f.stereo()) {
        attribs[i++] = GLX_STEREO;
        attribs[i++] = true;
    }
    if (f.stencil()) {
        attribs[i++] = GLX_STENCIL_SIZE;
        attribs[i++] = f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize();
    }
    if (f.alpha()) {
        attribs[i++] = GLX_ALPHA_SIZE;
        attribs[i++] = f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize();
    }
    if (f.accum()) {
        attribs[i++] = GLX_ACCUM_RED_SIZE;
        attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
        attribs[i++] = GLX_ACCUM_GREEN_SIZE;
        attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
        attribs[i++] = GLX_ACCUM_BLUE_SIZE;
        attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
        if (f.alpha()) {
            attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
            attribs[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
        }
    }
    if (f.sampleBuffers()) {
        attribs[i++] = GLX_SAMPLE_BUFFERS_ARB;
        attribs[i++] = 1;
        attribs[i++] = GLX_SAMPLES_ARB;
        attribs[i++] = f.samples() == -1 ? 4 : f.samples();
    }

    attribs[i] = XNone;
}
Ejemplo n.º 3
0
GLFormat::GLFormat(const QGLFormat & format)

:   m_majorVersion(format.majorVersion())
,   m_minorVersion(format.minorVersion())

,   m_redBufferSize  (format.redBufferSize())
,   m_greenBufferSize(format.greenBufferSize())
,   m_blueBufferSize (format.blueBufferSize())
,   m_alphaBufferSize(format.alpha() ? format.alphaBufferSize() : 0)

,   m_depthBufferSize  (format.depth()   ? format.depthBufferSize()   : 0)
,   m_stencilBufferSize(format.stencil() ? format.stencilBufferSize() : 0)

,   m_doubleBuffer(format.doubleBuffer())
,   m_stereo(format.stereo())

,   m_sampleBuffers(format.sampleBuffers())
,   m_samples(format.samples())

,   m_swapInterval(format.swapInterval())
{
  switch(format.profile())
    {
    default:
    case QGLFormat::NoProfile:
        m_profile = NoProfile; 
        break;
    case QGLFormat::CoreProfile:
        m_profile = CoreProfile; 
        break;
    case QGLFormat::CompatibilityProfile:
        m_profile = CompatibilityProfile; 
        break;
    };
}
QT_BEGIN_NAMESPACE

void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat)
{
    int redSize     = glFormat.redBufferSize();
    int greenSize   = glFormat.greenBufferSize();
    int blueSize    = glFormat.blueBufferSize();
    int alphaSize   = glFormat.alphaBufferSize();
    int depthSize   = glFormat.depthBufferSize();
    int stencilSize = glFormat.stencilBufferSize();
    int sampleCount = glFormat.samples();

    // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
    // type has been requested. So we must check QGLFormat's booleans too if size is -1:
    if (glFormat.alpha() && alphaSize <= 0)
        alphaSize = 1;
    if (glFormat.depth() && depthSize <= 0)
        depthSize = 1;
    if (glFormat.stencil() && stencilSize <= 0)
        stencilSize = 1;
    if (glFormat.sampleBuffers() && sampleCount <= 0)
        sampleCount = 1;

    // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
    // the best performance. The EGL config selection algorithm is a bit stange in this regard:
    // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
    // 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
    // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
    // order is special and described as "by larger _total_ number of color bits.". So EGL will
    // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
    // to say "If the requested number of bits in attrib_list for a particular component is 0,
    // then the number of bits for that component is not considered". This part of the spec also
    // seems to imply that setting the red/green/blue bits to zero means none of the components
    // are considered and EGL disregards the entire sorting rule. It then looks to the next
    // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
    // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
    // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
    // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
    // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will
    // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well.

    // Now normalize the values so -1 becomes 0
    redSize   = redSize   > 0 ? redSize   : 0;
    greenSize = greenSize > 0 ? greenSize : 0;
    blueSize  = blueSize  > 0 ? blueSize  : 0;
    alphaSize = alphaSize > 0 ? alphaSize : 0;
    depthSize = depthSize > 0 ? depthSize : 0;
    stencilSize = stencilSize > 0 ? stencilSize : 0;
    sampleCount = sampleCount > 0 ? sampleCount : 0;

    eglProperties.setValue(EGL_RED_SIZE,   redSize);
    eglProperties.setValue(EGL_GREEN_SIZE, greenSize);
    eglProperties.setValue(EGL_BLUE_SIZE,  blueSize);
    eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize);
    eglProperties.setValue(EGL_DEPTH_SIZE, depthSize);
    eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize);
    eglProperties.setValue(EGL_SAMPLES, sampleCount);
    eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0);
}
Ejemplo n.º 5
0
/*!
    Returns a window format for the OpenGL format specified by \a format.
*/
QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
    QSurfaceFormat retFormat;
    if (format.alpha())
        retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    if (format.depth())
        retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
    retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
    if (format.sampleBuffers())
        retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
    if (format.stencil())
        retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    return retFormat;
}
Ejemplo n.º 6
0
/*!
    Returns a window format for the OpenGL format specified by \a format.
*/
QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
    QSurfaceFormat retFormat;
    if (format.alpha())
        retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    if (format.depth())
        retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
    retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
    if (format.sampleBuffers())
        retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
    if (format.stencil())
        retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    retFormat.setMajorVersion(format.majorVersion());
    retFormat.setMinorVersion(format.minorVersion());
    retFormat.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(format.profile()));
    return retFormat;
}
Ejemplo n.º 7
0
int QGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
{
    switch(metric) {
    case PdmWidth:
        return size().width();
    case PdmHeight:
        return size().height();
    case PdmDepth: {
        const QGLFormat f = format();
        return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize();
    }
    default:
        qWarning("QGLPaintDevice::metric() - metric %d not known", metric);
        return 0;
    }
}
Ejemplo n.º 8
0
void GraphicsWindowQt::qglFormat2traits( const QGLFormat& format, osg::GraphicsContext::Traits* traits )
{
    traits->red = format.redBufferSize();
    traits->green = format.greenBufferSize();
    traits->blue = format.blueBufferSize();
    traits->alpha = format.alpha() ? format.alphaBufferSize() : 0;
    traits->depth = format.depth() ? format.depthBufferSize() : 0;
    traits->stencil = format.stencil() ? format.stencilBufferSize() : 0;

    traits->sampleBuffers = format.sampleBuffers() ? 1 : 0;
    traits->samples = format.samples();

    traits->quadBufferStereo = format.stereo();
    traits->doubleBuffer = format.doubleBuffer();

    traits->vsync = format.swapInterval() >= 1;
}
Ejemplo n.º 9
0
string glinfo::
        pretty_format(const QGLFormat& f)
{
    QGLFormat::OpenGLVersionFlags flag = f.openGLVersionFlags();

    stringstream s;
    s << "accum=" << f.accum() << endl
      << "accumBufferSize=" << f.accumBufferSize() << endl
      << "alpha=" << f.alpha() << endl
      << "alphaBufferSize=" << f.alphaBufferSize() << endl
      << "blueBufferSize=" << f.blueBufferSize() << endl
      << "depth=" << f.depth() << endl
      << "depthBufferSize=" << f.depthBufferSize() << endl
      << "directRendering=" << f.directRendering() << endl
      << "doubleBuffer=" << f.doubleBuffer() << endl
      << "greenBufferSize=" << f.greenBufferSize() << endl
      << "hasOverlay=" << f.hasOverlay() << endl
      << "redBufferSize=" << f.redBufferSize() << endl
      << "rgba=" << f.rgba() << endl
      << "sampleBuffers=" << f.sampleBuffers() << endl
      << "samples=" << f.samples() << endl
      << "stencil=" << f.stencil() << endl
      << "stencilBufferSize=" << f.stencilBufferSize() << endl
      << "stereo=" << f.stereo() << endl
      << "swapInterval=" << f.swapInterval() << endl
      << "" << endl
      << "hasOpenGL=" << f.hasOpenGL() << endl
      << "hasOpenGLOverlays=" << f.hasOpenGLOverlays() << endl
      << "OpenGL_Version_None=" << (QGLFormat::OpenGL_Version_None == flag) << endl
      << "OpenGL_Version_1_1=" << (QGLFormat::OpenGL_Version_1_1 & flag) << endl
      << "OpenGL_Version_1_2=" << (QGLFormat::OpenGL_Version_1_2 & flag) << endl
      << "OpenGL_Version_1_3=" << (QGLFormat::OpenGL_Version_1_3 & flag) << endl
      << "OpenGL_Version_1_4=" << (QGLFormat::OpenGL_Version_1_4 & flag) << endl
      << "OpenGL_Version_1_5=" << (QGLFormat::OpenGL_Version_1_5 & flag) << endl
      << "OpenGL_Version_2_0=" << (QGLFormat::OpenGL_Version_2_0 & flag) << endl
      << "OpenGL_Version_2_1=" << (QGLFormat::OpenGL_Version_2_1 & flag) << endl
      << "OpenGL_Version_3_0=" << (QGLFormat::OpenGL_Version_3_0 & flag) << endl
      << "OpenGL_ES_CommonLite_Version_1_0=" << (QGLFormat::OpenGL_ES_CommonLite_Version_1_0 & flag) << endl
      << "OpenGL_ES_Common_Version_1_0=" << (QGLFormat::OpenGL_ES_Common_Version_1_0 & flag) << endl
      << "OpenGL_ES_CommonLite_Version_1_1=" << (QGLFormat::OpenGL_ES_CommonLite_Version_1_1 & flag) << endl
      << "OpenGL_ES_Common_Version_1_1=" << (QGLFormat::OpenGL_ES_Common_Version_1_1 & flag) << endl
      << "OpenGL_ES_Version_2_0=" << (QGLFormat::OpenGL_ES_Version_2_0 & flag) << endl;

    return s.str();
}
Ejemplo n.º 10
0
static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f, int attribs[])
{
    int i = 0;
    attribs[i++] = WGL_SUPPORT_OPENGL_ARB;
    attribs[i++] = TRUE;
    attribs[i++] = WGL_DRAW_TO_PBUFFER_ARB;
    attribs[i++] = TRUE;

    if (has_render_texture) {
        attribs[i++] = WGL_BIND_TO_TEXTURE_RGBA_ARB;
        attribs[i++] = TRUE;
    }

    attribs[i++] = WGL_COLOR_BITS_ARB;
    attribs[i++] = 32;
    attribs[i++] = WGL_DOUBLE_BUFFER_ARB;
    attribs[i++] = FALSE;

    if (f.stereo()) {
        attribs[i++] = WGL_STEREO_ARB;
        attribs[i++] = TRUE;
    }
    if (f.depth()) {
        attribs[i++] = WGL_DEPTH_BITS_ARB;
        attribs[i++] = f.depthBufferSize() == -1 ? 24 : f.depthBufferSize();
    }
    if (f.redBufferSize() != -1) {
        attribs[i++] = WGL_RED_BITS_ARB;
        attribs[i++] = f.redBufferSize();
    }
    if (f.greenBufferSize() != -1) {
        attribs[i++] = WGL_GREEN_BITS_ARB;
        attribs[i++] = f.greenBufferSize();
    }
    if (f.blueBufferSize() != -1) {
        attribs[i++] = WGL_BLUE_BITS_ARB;
        attribs[i++] = f.blueBufferSize();
    }
    if (f.alpha()) {
        attribs[i++] = WGL_ALPHA_BITS_ARB;
        attribs[i++] = f.alphaBufferSize() == -1 ? 8 : f.alphaBufferSize();
    }
    if (f.accum()) {
        attribs[i++] = WGL_ACCUM_BITS_ARB;
        attribs[i++] = f.accumBufferSize() == -1 ? 16 : f.accumBufferSize();
    }
    if (f.stencil()) {
        attribs[i++] = WGL_STENCIL_BITS_ARB;
        attribs[i++] = f.stencilBufferSize() == -1 ? 8 : f.stencilBufferSize();
    }
    if ((f.redBufferSize() > 8 || f.greenBufferSize() > 8
         || f.blueBufferSize() > 8 || f.alphaBufferSize() > 8)
        && (QGLExtensions::glExtensions() & QGLExtensions::NVFloatBuffer))
    {
        attribs[i++] = WGL_FLOAT_COMPONENTS_NV;
        attribs[i++] = TRUE;
    }
    if (f.sampleBuffers()) {
        attribs[i++] = WGL_SAMPLE_BUFFERS_ARB;
        attribs[i++] = 1;
        attribs[i++] = WGL_SAMPLES_ARB;
        attribs[i++] = f.samples() == -1 ? 16 : f.samples();
    }
    attribs[i] = 0;
}
Ejemplo n.º 11
0
/*
========================
getDriverInfoString

 fills the GL info widget with text
========================
*/
QString CGLWidget::getDriverInfoString( void ) const
{
	// the context must be valied!
	if( !context()->isValid() )
		return QString( "<invalid OpenGL context>" );

	// read OpenGL infos
	QString text;
	text += tr( "Vendor:   %1\n" ).arg( (const char*)glGetString( GL_VENDOR ) );
	text += tr( "Renderer: %1\n" ).arg( (const char*)glGetString( GL_RENDERER ) );
	text += tr( "Version:  %1\n" ).arg( (const char*)glGetString( GL_VERSION ) );
	text += tr( "\n" );

	// print framebuffer format
	QGLFormat fmt = context()->format();
	text += tr( "Framebuffer Format:\n" );
	text += tr( " RGBA bits:    (%1,%2,%3,%4)\n" ).
				arg( fmt.redBufferSize() ).
				arg( fmt.greenBufferSize() ).
				arg( fmt.blueBufferSize() ).
				arg( fmt.alphaBufferSize() );
	text += tr( " Depth bits:   %1\n" ).arg( fmt.depthBufferSize() );
	text += tr( " Stencil bits: %1\n" ).arg( fmt.stencilBufferSize() );
	text += tr( "\n" );

	// shading language version
	if( fmt.openGLVersionFlags() & fmt.OpenGL_Version_2_0 )
	{
		QString version( (const char*)glGetString( GL_SHADING_LANGUAGE_VERSION ) );
		text += QString( "Shading Language Version: %1\n" ).arg( version );
	}

	// check for geometry shader
	bool hasGeoShader = false;
#ifdef CONFIG_ENABLE_GEOMETRY_SHADER
	hasGeoShader = ( NULL != strstr( (const char*)glGetString( GL_EXTENSIONS ), "GL_EXT_geometry_shader4" ) );
	if( hasGeoShader )
	{
		text += tr( "GL_EXT_geometry_shader4 available\n" );
	}
	else
	{
		text += tr( "GL_EXT_geometry_shader4 not supported\n" );
	}
#endif
	text += tr( "\n" );

	GLint i;
#define PRINT_CONSTANT(Name) \
	glGetIntegerv( Name, &i ); \
	text += tr( #Name " = %1\n" ).arg( i );

	PRINT_CONSTANT( GL_MAX_TEXTURE_SIZE );
	PRINT_CONSTANT( GL_MAX_TEXTURE_UNITS );
	PRINT_CONSTANT( GL_MAX_VERTEX_ATTRIBS );
	PRINT_CONSTANT( GL_MAX_VERTEX_UNIFORM_COMPONENTS );
	PRINT_CONSTANT( GL_MAX_VARYING_FLOATS ); // alias for GL_MAX_VARYING_COMPONENTS_EXT
	PRINT_CONSTANT( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_TEXTURE_IMAGE_UNITS );
	PRINT_CONSTANT( GL_MAX_TEXTURE_COORDS );
	PRINT_CONSTANT( GL_MAX_FRAGMENT_UNIFORM_COMPONENTS );

	if( hasGeoShader )
	{
		PRINT_CONSTANT( GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_VERTEX_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_VARYING_COMPONENTS_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT) ;
		PRINT_CONSTANT( GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT );
		PRINT_CONSTANT( GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT );
	}

#undef PRINT_CONSTANT

	return text;
}
Ejemplo n.º 12
0
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);
}