Texture quality difference between QWindow and QtQuick
-
Hi, I have a 3D scene which is based off of the window/glcontext from this example http://qt-project.org/doc/qt-5/qtgui-openglwindow-example.html, but I've recently switched over to QtQuick in order to take advantage of the GUI features so I won't have to roll my own, by following this example: http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html
Execpt for the window setups, the code is pretty much the same, but the Qt Quick scene has a noticeable tearing/grainy texture quality compared to the former. Would any of you have an idea why?
Here's two pictures showing both scenes, where the first is based on QtQuick and the latter is based on just the QWindow. http://imgur.com/Trrj6dN,8Izff4Z#0
You'll notice the latter image is much less of an eye sore. -
Just a show in the dark but did you tried displaying the openGL version?
@QGLFormat::majorVersion()@ -
The one based on the QWindow, I set up my own context to 3.3 Core by using the QSurfaceFormat object. The QtQuick renderer uses 4.4 Compatability.
Because I don't define my own context in the QtQuick implementation, I had to do a little hack to keep my previous code running.
I create a new QOpenGLFunctions_3_3_Core object and pass it around to any part needing to do any opengl calls:
@typedef QOpenGLFunctions_3_3_Core GLFuncs;
...
GLFuncs* funcs = new GLFuncs();
funcs->initializeOpenGLFunctions();
m_glcontroller->setFuncs(funcs);
...@If I don't do this, I get plagued with undefines to functions like glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);.
In a perfect world, I'd be able to define my own context like previously, and only let the QtQuick 4.4 renderer do the GUI stuff - there's not a whole lot of information on this subject that I've found, nor best practices, so I'm not sure how to do this 'the correct way'.
There's this video from KDAB https://www.youtube.com/watch?v=YqlaKY0a1hg that looks very interesting, but unfortunately, I've not found any of that sample code to have a look at.Edit: could the tearing have something to with not being doublebuffered? In the former implementation I do something like this in the render method:
@m_context->makeCurrent(this);
...
update(time);
render(time);
m_context->swapBuffers(this);@I've no idea what QtQuick does behind the scenes, but I assume it would swap by default?
-
Ok, so I've solved the problem, though I admit I'm not sure why it would behave like that.
Long answer:
When I linked the yt video to Sean Harmer's presentation of Qt Quick and Opengl, I noticed he said in comments how 5.2 lets the user set the context profile. So setting it to 4.3 Core or 3.3 Core both displays without any sort of tearing and everything is nice. I had tried setting context ersion earlier on when implementing the Qt Quick version, but got some strange errors (surely due to something else at the time) that would crash the app, and remembered I've read somewhere that Qt 5.1 still depends on compatability mode, and so I assumed it would crash due to this, thus leaving it at default.TLDR: switching from 4.4 Compatability to 4.3 Core using QSurfaceFormat with window->setFormat(..) made tearing go away.
I can only assume there is some driver bug or something..