简体   繁体   English

Android Opengl-es在纹理上制作透明背景,如何?

[英]Android Opengl-es make transparent background on a texture, how?

I have a texture with a black background. 我有黑色背景的纹理。

I d like to make a pixel color key transparency. 我想使像素颜色键透明。

My picture is a png file, but the background is not transparent, it is a BLACK(or red or yellow, etc) color. 我的图片是png文件,但背景不是透明的,而是黑色(或红色或黄色等)颜色。

How can i draw that texture without my background? 在没有背景的情况下如何绘制纹理?

this code not work: 此代码不起作用:

gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
gl.glEnable(GL10.GL_BLEND);

this code only work on transparent png's, 此代码仅适用于透明png,

thanks 谢谢

That wont work as it looks at the Alpha channel (hence GL_SRC_ALPHA) I would just advise removing the black background and changing it to a transparent one. 这在看Alpha通道时不起作用(因此GL_SRC_ALPHA),我只建议删除黑色背景并将其更改为透明背景。 That way that above code will work and I cant see why you wouldnt want to use the alpha channel 这样,上面的代码将起作用,我看不到为什么您不想使用Alpha通道

EDIT: Just to note what you are trying to do is known as masking 编辑:只是要注意您正在尝试做的被称为蒙版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM