In OpenGL ES, how do I load a texture that has transparent pixels?

后端 未结 2 1224
孤街浪徒
孤街浪徒 2020-12-24 02:40

And then have display correctly? An example would be having a round ball in a rectangle while being able to see another texture in the background.

edit: At the momen

2条回答
  •  抹茶落季
    2020-12-24 03:07

    The answer provided by @Virne is correct, and I was able to use it for Android devices with a few small modifications. The myImage object I used is a standard .png image with transparency.

    I created the texture using this:

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, myImage, 0);
    

    And (like Virne), I enabled alpha blend when rendering:

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

提交回复
热议问题