tags:

views:

2046

answers:

1

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 moment, when I load the texture the transparent pixels from the source image are displayed as black.

+6  A: 

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);
Virne
That works thanks! As a followup, how would I increase texture transparency after this?
Dimitris
Use color modulation.glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);Then set alpha component of the color to desired.glColor4f(255, 255, 255, alpha);
Virne