[Development] OpenGL Support in Qt5

Sean Harmer sean.harmer at kdab.com
Sat Jul 21 10:50:25 CEST 2012


On Monday 16 July 2012 20:22:24 Sean Harmer wrote:
> On 16/07/2012 19:54, gunnar.sletta at nokia.com wrote:
> > On Jul 16, 2012, at 4:54 PM, ext Sean Harmer wrote:
> >> On Monday 16 July 2012 07:21:23 Thiago Macieira wrote:
> >>> On segunda-feira, 16 de julho de 2012 15.12.15, Sean Harmer wrote:
> >>>> On Monday 16 July 2012 07:08:38 Thiago Macieira wrote:
> >>>>> I'm asking for Qt 5.0: what should we tell Linux distributors to
> >>>>> configure
> >>>>> qtbase with? Considering what requirements qtwayland has, I think it
> >>>>> needs
> >>>>> to be -opengl es2.
> >>>>> 
> >>>>> Correct?
> >>>> 
> >>>> If using wayland then yes I believe so.
> >>>> 
> >>>> If using xcb backend then -opengl desktop works fine.
> >>> 
> >>> There's only one build of Qt. The choice is made at compile-time of
> >>> qtbase,
> >>> not at run-time like the platform plugin.
> >>> 
> >>> So everyone should use OpenGL ES 2.
> >> 
> >> Unless they want to support applications that use legacy OpenGL calls or
> >> develop new applications that use modern desktop GL.
> >> 
> >> There seems to be a dependency issue here that needs resolving. Qtbase
> >> itself has a configure time switch for OpenGL ES vs Desktop whereas the
> >> QPA plugins can be decided upon at runtime. Is there some way we can
> >> move the GL decision to be runtime too I wonder?
> > 
> > We've talked about in the past that Qt could internally resolve all OpenGL
> > functions and expose proxy functions which at run time are linked towards
> > the correct library... Incidentally, exactly the problem the patch that
> > started this thread solves, if it gets expanded to include every
> > extension in the Khronos registry.
> I almost have this aspect completed now. Should be done in the next day
> or so. Once ready I'll update the patchset.

The patchset now contains the output of the code generator including support 
for all OpenGL extensions in the Khronos registry (for those that actually 
define entry points).

There is still some tidying up to do but it is already usable with code like 
this:

    // Query extensions
    QList<QByteArray> extensions = m_context->extensions();
    qSort( extensions );
    qDebug() << "Supported extensions (" << extensions.count() << "):";
    foreach ( const QByteArray &extension, extensions )
        qDebug() << "    " << extension;

    // Get an extension object
    QOpenGLExtension_ARB_draw_buffers* ext = 0;
    if ( m_context->hasExtension( "GL_ARB_draw_buffers" ) )
    {
        ext = m_context->extension<QOpenGLExtension_ARB_draw_buffers>();
        ext->initializeOpenGLFunctions( m_context );
    }

    ...

    // Use extension to draw to multiple buffers
    GLenum buffers[] = { GL_BACK, GL_AUX0 };
    ext->glDrawBuffersARB(2, buffers)

Cheers,

Sean



More information about the Development mailing list