OpenGL transparent images have black in them

后端 未结 4 558
醉酒成梦
醉酒成梦 2021-01-13 03:31

I am working on a game for Android and I was wondering why whenever I draw images with transparency there seems to always be some black added to the transparent parts. This

4条回答
  •  爱一瞬间的悲伤
    2021-01-13 04:23

    Are you using linear sampling? My thought could be if you have a very small image (less than say 30-40 pixels in dimension), you could be getting interpolated alpha values between the inside of the circle (alpha = 1) to the outside of the circle (alpha = 0). This would give you intermediate alpha values that result in the kind of blur effect.

    Try the following code when you have the circle texture bound:

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    

    Maybe you can host the actual texture that you're using such that we can inspect it? Also please post your drawing code if this doesn't help.

提交回复
热议问题