iPhone opengl es alpha-blending. I have black color in edge

时光毁灭记忆、已成空白 提交于 2019-12-04 06:00:22

Does your image have pre-multiplied alpha? Then you should be using

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

Here is some explanations of what it is.

Note: I rewrote the answer after doing some research. The article rotoglup mentioned has some insight on what's going on and it makes more sense then my original formula. I also tried to see what other people are using in their code and it looks like this formula is the most used one. It's amazing how such a basic thing in 3D graphics as alpha blending can be so controversial and everyone seems to reinvent the wheel and come up with their own solutions.

Just check the view on which you are drawing is opaque or not. set opaque property to false

One way this can occur is if you haven't correctly set your glTexParameteri for minification and magnification filters correctly, along with your clamp method. See Adam Redwood's comment here. Note issues of power-of-two textures, texture boundaries etc. may also come into play.

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!