Image displayed with black background OPENGL ES Android

偶尔善良 提交于 2019-12-12 03:19:26

问题


Hi I am playing around with OPENGL Es on ANdroid and I am trying to display an image on my app. When I display the image ( image specs is 64x64 pixels ) I get a black background on the image but when I put this code:

 public void draw(GL10 gl) {
... 
.. 
 gl.glAlphaFunc( GL10.GL_GREATER, 0 ); 

The black background disappears but I get strange colors in my image.

Does anybody have an idea on how to fix this?


回答1:


You need to use blending. Something like this should work:

gl.glEnable(gl.GL_BLEND);
gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINE_SRC_ALPHA);

The fact that you can use glAlphaFunc and get close to your result suggests that the image itself is okay at least.



来源:https://stackoverflow.com/questions/10063279/image-displayed-with-black-background-opengl-es-android

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