Well I found out that you can apply the alpha channel to the image outside of the program, this would make things a lot easier for me so I have created the alpha channel in photoshop.
I’ve then loaded the image using devIL and applied it as a texture. This is the code I have used:
void loadImage(){
glEnable(GL_TEXTURE_2D); //Enable Texture Mapping
ilInit();
//Load world texture
ilGenImages(1, &imageName); //Generate image name
ilBindImage(imageName); //Bind image name
ilLoadImage((const ILstring)"E:\BlankWindow256.bmp");
ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); //Convert image into RGB colour format and check its in unsigned byte format
glGenTextures(1, &textureName);
glBindTexture(GL_TEXTURE_2D, textureName); //Bind texture name
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //Use linear interpolation magnification an minifying filters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData()); //Define all texture parameters
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
glColor4f(1.0, 1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, textureName);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(200, -280, -350);
glTexCoord2f(0.0, 1.0); glVertex3f(200, -130, -350);
glTexCoord2f(1.0, 1.0); glVertex3f(340, -130, -350);
glTexCoord2f(1.0, 0.0); glVertex3f(340, -280, -350);
glEnd();
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
}
This displays the image on screen as a texture as expected but no part of it is transparent. I’ve tried making the file a 32bit .bmp, a .tga and a .png but I get the same result with either of these so I don’t think the problem lies the devIL library, I think it’s either my code above has something wrong with it, or I havent created the alpha channel correctly.
I’ve also tried various different parameters in the glAlphaFunc() but still nothing. I either get the entire image opaque, or the entire image is transparent so I cant see it at all.
Here’s a screenshot of the image in photoshop if it helps:
http://img209.imageshack.us/img209/3521/photoshopsnapqw5.jpg
Any ideas?
Thanks very much