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

后端 未结 2 1216
孤街浪徒
孤街浪徒 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:18

    For iPhone and N95 this works:

    If you are loading texture from raw data, set internal and source format to GL_RGBA.

    glTexImage2D(GL_TEXTURE_2D, 0, 
        GL_RGBA,
        textureWidth,
        textureHeight, 
        0, 
        GL_RGBA,
        GL_UNSIGNED_BYTE,
        pointerToPixels);
    

    And when rendering, enable alpha blend:

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    

提交回复
热议问题