[Interest] [Qt 5, OS X] Does OpenGL 3 Core Profile work (with Qt APIs)?
Samuel Rødal
samuel.rodal at digia.com
Mon Apr 22 12:08:07 CEST 2013
On 04/22/2013 10:40 AM, Till Oliver Knoll wrote:
> 2013/4/20 James Turner <james.turner at kdab.com>:
>>
>> On 18 Apr 2013, at 09:09, Till Oliver Knoll <till.oliver.knoll at gmail.com>
>> wrote:
>>
>> So is OpenGL 3.x Core actually supposed to work with Qt 5? Or is this
>> still work in progress?
>>
>>
>> It works fine, but the legacy QGL APIs don't help you much. Rough
>> pseudo-code which works for me:
>>
>> QWindow *win = new QWindow
>> win->setSurfaceType( OpenGLSurface );
>>
>> QSurfaceFormat format;
>> format.setMajorVersion( 3 );
>> format.setMinorVersion( 2 );
>> format.setProfile( QSurfaceFormat::CoreProfile );
>
> Thanks for the hint about QWindow/OpenGLSurface - didn't know that new
> Qt 5 API yet ;)
Sean did a nice write-up on what's happening on the OpenGL side in Qt 5:
http://www.kdab.com/opengl-in-qt-5-1-part-1
> And I figured out by now why the previously mentioned "OpenGL Windows"
> example "did not work":
>
> http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html
>
> It uses the said QWindow API and basically re-implements the QGLWidget
> "initialise-/paint-/resizeGL" functionality - without actually
> rendering anything, hence my impression that "it did not work".
> I yet have to try out that "TriangleWindow" example code and see
> whether it actually works.
examples/opengl/hellowindow is also QWindow-based. Also, any QtQuick 2.0
application will use QWindow and QOpenGLContext and no QWidget or
QGL*-classes.
> However, even it it would work and apart from the huge performance
> issues: it would be of no use to me, because QWindow is not derived
> from QWidget, is it? So what's the use of having a GL based windows in
> a *desktop* application (except for "full-screen" usage maybe)? I
> really need a QGLWidget...
In 5.1 you can use QWidget::createWindowContainer() to embed a QWindow
in a QWidget-hierarchy. But yes, we should probably have a QOpenGLWidget
to replace QGLWidget at some point (so that the QtOpenGL module can be
fully deprecated).
> And apart from QGLWidget and QGLFormat - which apparenty are /not/
> deprecated in Qt 5, and I don't see any QOpenGLFormat, for instance -
> I am not using any deprecated Qt OpenGL functionality AFAICT: I
> replaced the QGLShaderProgram with QOpenGLShaderProgram.
QSurfaceFormat is meant to be the replacement for QGLFormat.
> My assumption/expectation is off course that QOpenGLShaderProgram
> /should/ work within a QGLWidget - with a Core 3.2 GL context, that
> is.
>
> I'll investigate more, especially I will start over from an example
> that actually /does/ work from the very beginning, and try to squeeze
> that into a QGLWidget with a Core 3.2 GL context, using QOpenGLShader.
Hmm yes, I don't see why QOpenGLShaderProgram shouldn't work with a
QGLWidget. Internally QGLWidget (well QWidget really) and QGLContext are
implemented on top of QWindow and QOpenGLContext now (in qwidget_qpa.cpp
and qgl_qpa.cpp respectively).
--
Samuel
More information about the Interest
mailing list