[SOLVED] Cannot set QQuickItem's OpenGL version
-
Hi,
I have a QML application and I need to integrate an OpenGL window. So I did:
GLViewport.h
@ class GLViewport : public QQuickItem{...}
@GLViewport.cpp
@ GLViewport::GLViewport()
{
connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(HandleWindowChanged(QQuickWindow*)), Qt::DirectConnection);
setFlags(QQuickItem::ItemHasContents);
}void GLViewport::HandleWindowChanged(QQuickWindow *win) { if (win) { win->setSurfaceType(QSurface::OpenGLSurface); QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGL); format.setSamples(4); format.setVersion(3, 2); // <<== this puts a mess! format.setProfile(QSurfaceFormat::CoreProfile); win->setFormat(format); win->create(); QOpenGLContext *context = new QOpenGLContext; context->setFormat(format); context->create(); if (!context->isValid()) { std::cout << "ERROR: cannot set OpenGL context" << std::endl; } context->makeCurrent(win);
[...]
} }
@
However, the line setFormat(3,2) puts a real mess. Basically, if I comment it, everything works. I have a window with a OpenGL 2.0 and a "internal context" with OpenGL 4.4. Problem is, my viewport needs an OpenGL 3.2 context for drawing our things. How can I achieve that then?
Thanks for any help!
UPDATE
If fact, it does NOT work with "OpenGL under QML example":http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html either. If I try to change OpenGL version, I get a black background when doing setVersion(3,2). -
Anyone running in the same issues?
Best regards.
-
Forget about asking Qt to use a specific opengl version. It simply does not work on Mac OSX for the moment...