   SDL and OpenGL Transparency/Colorkeying
  I am working on a simple program to draw spaceships onto a scene.The spaceships are stored in bmp files with black colorkeys. Here is my drawing function:void Ship::show(int whichTexture){    glLoadIdentity();    glTranslatef(x, y, 0);  glEnable(GL_BLEND);    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);    glBindTexture(GL_TEXTURE_2D, texture[whichTexture]);  glBegin( GL_QUADS );   glTexCoord2i(0, 0);  glVertex3f( 0, 0, 0 );   // upper left   glTexCoord2i(1, 0);  glVertex3f( w, 0, 0 );   // upper right   glTexCoord2i(1, 1);  glVertex3f( w, h, 0 );   // bottom right   glTexCoord2i(0, 1);  glVertex3f( 0, h, 0 );   // bottom left    glEnd();   glDisable(GL_BLEND);   glLoadIdentity();}Issue:When I render using: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)Then the ships are displayed without the black area but the ships are also partly transparent.I have a function that is supposed to replace the black pixels with transparent alpha pixels and that seems to have absolutely no effect on this issue.  I can comment the whole section out and it works the same.Pixel replacement function:ship1 = load_image("Federation Eagle Cruiser.bmp");   if( ship1 != NULL )  { // // Loop through every pixel in the SDL Surface  // check its color // if it is true back, set it to transparent. //    int i, j; for( i = 0; i < ship1->w; i++ ) {for (j = 0; j < ship1->h; j++){    Uint8 r;    Uint8 g;    Uint8 b;    Uint8 a;    SDL_LockSurface(ship1);    Uint32 onePixel = getpixel(ship1, i, j);    SDL_UnlockSurface(ship1);    SDL_GetRGBA(onePixel, ship1->format, &r, &g, &b, &a);  // does our rgb match color key of 0,0,0 black?    if (r ==0 && g == 0 && b == 0)    {  // if so, then set alpha to transparent  a = 0;  Uint32 newPixel = SDL_MapRGBA(ship1->format, 0, 0, 0, 0);  SDL_LockSurface(ship1);  putpixel(ship1, i, j, newPixel);SDL_UnlockSurface(ship1);    }} } } // <end if ship!=nullWhat I want is a fully opaque ship with a fully transparent black background.  How can I modify this code to achieve that result?   
  Something is definitely wrong here:I put the int d = 0; into there for an else if just to see during debugging if it would ever get there.  The program thinks that r, g, and b are always 0.  Why? int i, j; for( i = 0; i < ship1->w; i++ ) {for (j = 0; j < ship1->h; j++){    Uint8 r;    Uint8 g;    Uint8 b;    Uint8 a;    SDL_LockSurface(ship1);    Uint32 onePixel = getpixel(ship1, i, j);    SDL_UnlockSurface(ship1);    SDL_GetRGBA(onePixel, ship1->format, &r, &g, &b, &a);  // does our rgb match color key of 0,0,0 black?    if (r ==0 && g == 0 && b == 0)    {  // if so, then set alpha to transparent  a = 0;  Uint32 newPixel = SDL_MapRGBA(ship1->format, 0, 0, 0, 0);  SDL_LockSurface(ship1);  putpixel(ship1, i, j, newPixel);SDL_UnlockSurface(ship1);    }    else if (r !=0 || g != 0 || b != 0)    {  // if so, then set alpha to transparent  int d = 0;    } } }Finally, here is my getPixel function:Uint32 getpixel(SDL_Surface *surface, int x, int y){    int bpp = surface->format->BytesPerPixel;    /* Here p is the address to the pixel we want to retrieve */    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;    switch(bpp) {    case 1:   return *p;   break;    case 2:   return *(Uint16 *)p;   break;    case 3:   if(SDL_BYTEORDER == SDL_BIG_ENDIAN)  return p[0] << 16 | p[1] << 8 | p[2];   else  return p[0] | p[1] << 8 | p[2] << 16;   break;    case 4:   return *(Uint32 *)p;   break;    default:   return 0;  /* shouldn't happen, but avoids warnings */    }}