I sometimes disable depth buffer writing via glDepthMask(GL_FALSE) during the alpha rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO with the Adreno GPU for example, I end up with the frame buffer being complete garbage (I see traces of the meshes I rendered somewhere, but the entire screen is mostly trashed).

If I force glDepthMask to be true the entire time, everything works fine.

I need glDepthMask to be off during parts of the alpha rendering. What can cause the framebuffer to get destroyed by turning the depth writing off?

I do clear the depth buffer initially, and the majority of the screen has pixels rendered with depth writing turned on first before I do additional drawing with it turned off.

  • \$\begingroup\$ Can I get more detail on your problem? I assume you have a normal rendering code with glDepthMask(false), render transparencies, glDepthMask(true)? Any screenshots of what's happening? \$\endgroup\$ – Jari Komppa Mar 14 '11 at 12:31
  • \$\begingroup\$ @Jari: I'll attach some tomorrow. This is on a borrowed phone, I don't have an Adreno-based phone myself. But it's basically like you said - clear depth with 1.0, glDepthMask(true), render opaque objects, glDepthMask(false), render alpha objects. Unless I remove the second call, the frame buffer shows mostly the clear control and a few untextured shapes of objects I was rendering. I'll borrow the phone today to do a few more experiments. \$\endgroup\$ – EboMike Mar 14 '11 at 15:43
  • \$\begingroup\$ Try setting the glDepthMask back to true after you've rendered the transparencies and before you flip. \$\endgroup\$ – Jari Komppa Mar 14 '11 at 19:59
  • \$\begingroup\$ @Jari: That did indeed fix it. Can you make that an answer so I can accept it? \$\endgroup\$ – EboMike Mar 15 '11 at 22:25

Having glDepthMask disabled during flip may cause the problem. Probably a driver issue; best to update the drivers (i.e, get a new ROM) at some point, but as a workaround keep it turned on as much as possible.

EDIT: actually, glDepthMask seems to affect glClear, so this may not be a driver issue after all.

  • \$\begingroup\$ Duh, glDepthMask affects glClear. Okay, that actually makes a lot of sense. Thanks! \$\endgroup\$ – EboMike Mar 16 '11 at 6:20

Shouldn't glDisable(GL_DEPTH_TEST) disable writes to the depth buffer as well? Maybe that fixes it for you.

  • \$\begingroup\$ No, I want depth testing turned on, but writing turned off. \$\endgroup\$ – EboMike Mar 5 '11 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.