mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
328 stars 104 forks source link

Can't get glDepthFunc working #32

Open gsohler opened 5 years ago

gsohler commented 5 years ago

I was writing a small 3D viewer where i want to display certain 3d Objects using Python3, OpenGL, Shaders and ElementLists. Everything works fine, apart glDepthFunc does not appear to work even when i use glDepthGFunc(GL_NEVER) it draws all triangles of my "cube"

Attached is a testcase which includes my viewer and a picture where glDepthFunc failed to work as expected.

Also in My3DViewer there is a glBeginLines() which should not be there, but it does not work without ...

Please give me some hints to correct my code .

Thank you

testcase.zip

mcfletch commented 4 years ago

I do not see the effect you're showing in your wrong.png result when I run your example.

When I run on a Kubuntu 18.04 machine I see an empty black screen. I gather the expectation is that there would be a cube in the middle of the screen, but I haven't traced through the code to see why that is not currently happening.

glDepthFunc works in my own code, such as the OpenGLContext shadow demo, but there doesn't seem to be any reason for you to be explicitly specifying it here. That is, you seem to want the default behaviour of using the depth buffer (only write pixels where depth is less than current), rather than some specific special effect, such as allowing a single pixel to be rewritten multiple times or the like.