PDA

View Full Version : qt quick with opengl bug ?



sajis997
3rd January 2015, 07:02
Hello forum,

I just noticed that opengl rendering as underlay comes up with artifacts without the following snippet inside the render function:



glDepthMask(true);


i used to know that by default it is set to true. Qt Quick 2 renders using opengl , is it disabling it somehow ?


Again I have a functional opengl application that is doing the lighting calculation properly while porting to Qt 5 with qml UI. It is too early to mention that it is somewhow affected by qml. There is no changes been made to the shader file, but it not doing right with Qt 5.


Thanks

wysota
3rd January 2015, 08:44
If you are rendering as an underlay then QtQuick is rendering after you so how would it affect your rendering?

sajis997
23rd January 2015, 18:14
Hi

If i initialize some opengl related flag during the initialization , do they not remain effective ? I am setting the following flag during initialization , but they are not effective while rendering the scene :



void TeapotTessellation::initialise()
{

.....................
.....................

glEnable(GL_DEPTH_TEST);

glDepthFunc(GL_LEQUAL);

glEnable(GL_CULL_FACE);

glDepthMask(true);

}


If i , instead put the above flags inside the render() function , they are effective. Why is that so ?

render() is called every frame as follows:



void TessellationSceneItem::handleWindowChanged(QQuickW indow *win)
{
if(win)
{
//define the opengl surface format
//with the most modern profile
//while retaining the compatibility profile
QSurfaceFormat f = win->format();
f.setMajorVersion(4);
f.setMinorVersion(3);
f.setSamples(4);
f.setStencilBufferSize(8);
f.setProfile(QSurfaceFormat::CompatibilityProfile) ;

win->setFormat(f);

win->setClearBeforeRendering(false);

.............................
.............................

//make the connection to render the raw opengl scene before the scene graph rendering
//and we make sure that the slot finishes the rendering before further execution
connect(win,SIGNAL(beforeRendering()),mTessScene,S LOT(paint()),Qt::DirectConnection);
}

}


The slot paint() works as follows:



void TeapotTessellation::paint()
{
if(!mInitialized)
initialise();

resize(mViewportWidth,mViewportHeight);
render();
}


I am inpecting my own code since I have the same application done with GLFW and there the lighting calculation is working fine. While porting to Qt 5 with opengl underlay and qtquick overlay I could not get the lighting working.

I wonder why ? I am using same shader . I am looking for the flaw. Some hint is appreciated.

Thanks

wysota
23rd January 2015, 22:12
Hi

If i initialize some opengl related flag during the initialization , do they not remain effective ?
No, the flag can be overriden by Qt Quick. It's all written in the docs, you know.