开发者

is there any conflict between GL_DEPTH_TEST and alpha blending in openGL?

I'm drawing some "2D" pictures. Let's say, pic A in the background draw first, pic B in foreground draw later than A. and there are some transparent area in B. So when i enable GL_DEPTH_TEST, B should cover A but those transparent area.

the actual result i got here is strange, the B did cover A, but the transpa开发者_开发百科rent area show the very background instead of A which it should be.

i use glFrustum as GL_PROJECTION, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), glDepthFunc(GL_LEQUAL) is there some settings i missing or what?


There shouldn't be any conflict of the sort you discuss. The depth buffer can hold only one depth per pixel, so transparency can be an issue because it's not really accurate to say that each pixel is composed of data from a single depth.

The net effect is that if you draw something partially transparent then try to draw something behind it, the depth buffer says not to draw. So while you should be able to see the thing behind, you can't.

In your case, what you're seeing would be expected behaviour if you were drawing B (in the foreground) and then A (in the background). Is it possible some aspect of your code is giving you an unexpected drawing order?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜