   Color Key Transparancy
  I'm trying to edit the texture data in a variable after auxDIBImageLad has been called and set the alpha components to 0 if full blue is that color. This is my code:bool LoadTransTextureFile(char *TextureFile, int TextureIDSpot){//load a transparent TextureFILE *FileHandle = fopen(TextureFile, "r");if(!FileHandle)return false;fclose(FileHandle);AUX_RGBImageRec *TexRec;TexRec = auxDIBImageLoad(TextureFile);if(TexRec){for(int i=0;i<=sizeof(TexRec->data);i=i+3){if(TexRec->data == 0 && TexRec->data[i+1] == 0 && TexRec->data[i+2] == 255)TexRec->data[i+3] = 0; //set alpha attributes}glGenTextures(1, &TextureID);MD_Tex[TextureIDSpot] = TextureID;glBindTexture(GL_TEXTURE_2D, TextureID);//generate MipMapsgluBuild2DMipmaps(GL_TEXTURE_2D, 3, TexRec->sizeX, TexRec->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, TexRec->data);//set filtering optionsglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);// Linear FilteringglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);// Linear Filtering}return true;}But it crashes….   </i> <SPAN CLASS=editedby>[edited by - Agent666 &#111;n February 6, 2004 9:49:31 AM]</SPAN>   
  The glaux AUX_RGBImageRec structure does not contain an alpha channel.  You need to copy the data into a new buffer before you can set the alpha, i.e.:GLubyte* newBuffer = new GLubyte[TexRec->sizeX * TexRec->sizeY * 4];for (int index = 0; index < TexRec->sizeX * TexRec->sizeY; ++index){std::copy(TexRec->data + (index * 3), TexRec->data + (index * 3) + 3, newBuffer + (index * 4));if (TexRec->data[(index * 3) + 0] == 0 && TexRec->data[(index * 3) + 1] == 0 && TexRec->data[(index * 3) + 2] == 255){newBuffer[(index * 4) + 3] = 0;}else{newBuffer[(index * 4) + 3] = 255;}}  Enigma ;  That is very well, but newBuffer won''t work with gluBuild2DMipMaps without a structure defintion for newBuffer.like this will not work:gluBuild2DMipmaps(GL_TEXTURE_2D, 3, newBuffer->sizeX, newBuffer->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, newBuffer->data);What is a name of a structure that holds alpha channel data and can be passed to GluBuild2DMipMaps ;  lol forget i said that last post, can''t believe i said that, too late at night. ;  You don''t need a structure.  You already have the width and height of the texture, but now your data is RGBA instead of RGB, so pass it to gluBuild2DMipmaps as:gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, TexRec->sizeX, TexRec->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, newBuffer);  Also note that I changed the second parameter to GL_RGBA. ''3'' is deprecated and means ''GL_RGB'', which wouldn''t give you an alpha channel anyway.Don''t forget to delete[] newBuffer afterwards.Enigma ;  Ok, when i show the polygons they are not transparent where the transparent colors are, do i need to enable any testing or gl_blend? ;  Either:glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glEnable(GL_BLEND);  or:glAlphaFunc(GL_GREATER, 0.5);glEnable(GL_ALPHA_TEST);  Enigma ;  2nd one worked, first one didn''t 