Qt OpenGL: Depth Test not working

I am working on Qt/openGL and I have some issue to activate my depth buffer.

At every frame, I activate the following states: glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL);

Plus I checked that the size of my depth buffer is not null (glGetIntegerv(GL_DEPTH_BITS) gives me 24, which is the expected value) however the depth test is not working and some fragments that should be discarded by depth test are not.

Any idea?

Answers


OK, so problem fixed! Here is the method I used if anyone gets the same issue.

I installed GDebugger, and checked that depth buffer was indeed not written. I exported the openGL current state and here are the states relative to depth test:

GL_DEPTH_BIAS=0
GL_DEPTH_BITS=24
GL_DEPTH_CLEAR_VALUE=2147482496
GL_DEPTH_FUNC=GL_LESS
GL_DEPTH_RANGE={0, 1}
GL_DEPTH_SCALE=1
GL_DEPTH_TEST=TRUE
GL_DEPTH_WRITEMASK=FALSE

Everything seems okay except GL_DEPTH_WRITEMASK which is false. I activated it using:

glDepthMask(GL_TRUE); 

and everything is working!

EDIT: Actually, the activation of the state must be done at every frame for correct rendering


I was facing the same problem, and setting the GL_DEPTH_BUFFER_BIT in the glClear function solved my problem.


Need Your Help

Python/Pandas: counting the number of NaN in each row

pandas count row dataframes nan

I've got a dataset with a big number of rows. Some of the values are NaN, like this:

Destroy cookie not working in sub directory

php cookies destroy

I think there might be something I don't get about cookies. I'm trying to destroy a cookie when I click on a button but the cookie stays. I know that instructions for cookies must be before html co...