Sign up ×

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.

share|improve this question
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? –  Jari Komppa Mar 14 '11 at 12:31
@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. –  EboMike Mar 14 '11 at 15:43
Try setting the glDepthMask back to true after you've rendered the transparencies and before you flip. –  Jari Komppa Mar 14 '11 at 19:59
@Jari: That did indeed fix it. Can you make that an answer so I can accept it? –  EboMike Mar 15 '11 at 22:25

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
Duh, glDepthMask affects glClear. Okay, that actually makes a lot of sense. Thanks! –  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.

share|improve this answer
No, I want depth testing turned on, but writing turned off. –  EboMike Mar 5 '11 at 2:35

Your Answer


