Reputation: 8160
In OpenGL, is it possible, to draw a sequence of polygons that doesn't check for depth (so they will always be drawn in front of other polygons drawn before it, regarding of their z position)
but also at the same time, they still write to the depth buffer?
I suppose this is doable using shaders, but right now I have no access to that.
Upvotes: 8
Views: 4189
Reputation: 18015
Not strictly speaking (from the man page):
the depth buffer is not updated if the depth test is disabled.
But... you can have the depth test enabled, while not having any fragment fail the test:
glDepthFunc(GL_ALWAYS);
glEnable(GL_DEPTH_TEST);
Of course, you get the last Z written by doing that, not the closest to the view.
Upvotes: 19
Reputation: 12184
You can only achieve that using two passes. First one is to populate the depth buffer only using a color mask:
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
Second pass you enable color writing again, disable depth test and render your sequence of polygons in order.
Upvotes: 4