[Interest] QML / OpenGL / scene graph problem.

Sean Harmer sean.harmer at kdab.com
Sun Dec 1 17:24:48 CET 2013


On 01/12/2013 16:00, Guido Seifert wrote:
> Hi and help!
> I have a problem here. Unfortunately I am not very experienced with OpenGL and need a hint in which
> direction I have to look to fix the following problem.
> I took the HelloGL code from the examples and wanted to make it into a QML widget. I cannot my
> experiments are a total failure, but unfortunately they are far from a total success also.
> https://imageshack.com/i/59c6eip
> https://imageshack.com/i/jmg97op

Those images are fairly typical of artefacts you get when depth 
testing/writing is not enabled. Be aware that the final phase of Qt 
Quick 2 rendering is typically to render transparent objects using alpha 
blending. To do this QQ2 renders these items from back to front with 
blending enabled to get the correct results. However, the important part 
of this is that the depth buffer is disabled for writes.

This means that when you get to render your object, it is quite likely 
that depth writes are still disabled. I see from your code that you are 
enabling depth testing. However, without any sane values in the depth 
buffer this won't work. To enable depth writes, try calling 
glDepthMask(true) before you render any geometry.

Also please note that there is a new helper function to return the 
OpenGL state to it's default (i.e. to undo the changes that the QQ2 
renderer makes). The function is:


Amongst other things, this function also enabled depth writes as 
suggested above. Whether you choose to use this helper or to only alter 
the state that you need is your choice.

Hope this helps,


Dr Sean Harmer | sean.harmer at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions

More information about the Interest mailing list