PNG alpha channel not rendered in openGL(SDL_image used)+"manually" creating images in code

I am trying to read in a PNG image which has a transparent region .The picture is as shown in fig3 (picture below) with the transparent regionn being the blue surrounding area. So the pic appears as in fig 1.I have verified that the transparent region is stored correctly as in windows folder filmstrip view it appears as 1.I used irfanview to set the transparent region. then i use thecode below to read in the picture below which is modified code from Nehe tutorial 8 on Alpha Blending. I used SDL_image to load the png

This is the referenced picture with all figures numbered:-
Image Hosted by ImageShack.us

http://img487.imageshack.us/img487/3448/p6lq5.jpg

1.The png is loaded using a load_image() function(given at end).The code below “// Create Linear Filtered Texture” should load the texture correctly

glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureImage[0]->w, TextureImage[0]->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage[0]->pixels);

Its give in NEHE tutorial that GL_RGBA must be passed to above function & of course the no. of color components is 4(?).Yet the texture appears as in Fig 4. With blending enabled it appears as in figure 6.The pixels are not correct at all.

2.The code below “// CreateMipMapped Texture” loads the texture correctly but is without the alpha channel. The the cube appears as in fig 2 & with blending as in fig 5. Here as the alpha channel is ignored it does not make any difference how i save the pic(blue transparent region or not)

3.Then i tried to generate a texture “manually” using the code below “//Create image manually” & create a texture out of it(below “// Create Nearest Filtered Texture”). The intention is to create a blue square 32 by 32 in size.But i get a blank when i try to view the cube…absolutely dark screen ,nothing at all.!!

#define RMASK 0x000000FF
#define GMASK 0x0000FF00
#define BMASK 0x00FF0000
#define AMASK 0xFF000000

//Loads textures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator

SDL_Surface* TextureImage[1];                    // Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1);               // Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=load_image("Data/glass.png"))
{
    Status=TRUE;                                    // Set The Status To TRUE

    glGenTextures(3, &texture[0]);                    // Create Three Textures
    
    //Create image manually
    unsigned int img[32*32];
    memset(img,0xFFFF0000,sizeof(img));
    SDL_Surface* imgsurf;
    imgsurf=SDL_CreateRGBSurfaceFrom( img, 32, 32, 32, 4*32, RMASK, GMASK, BMASK, AMASK );
    if(imgsurf==NULL)
        MessageBox(NULL,"Surface null",     "Error",  MB_OK | MB_ICONERROR);

    // Create Nearest Filtered Texture
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, imgsurf->w, imgsurf->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imgsurf->pixels);

    // Create Linear Filtered Texture
    glBindTexture(GL_TEXTURE_2D, texture[1]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureImage[0]->w, TextureImage[0]->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage[0]->pixels);

    // Create MipMapped Texture
    glBindTexture(GL_TEXTURE_2D, texture[2]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->w, TextureImage[0]->h, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->pixels);
}

if (TextureImage[0])                                // If Texture Exists
{
    SDL_FreeSurface(TextureImage[0]);                // Free The Texture Image Memory
                                
}

 glMatrixMode(GL_TEXTURE);
 glScalef(1.0f, -1.0f, 1.0f);
 glMatrixMode(GL_MODELVIEW);

return Status;                                        // Return The Status

}

Here is the load_image function-superfluous really as i could have put up the little code above

//Loads a texture BMP image
SDL_Surface load_image( std::string filename )
{
//Temporary storage for the image that’s loaded
SDL_Surface
loadedImage = NULL;

//Load the image
loadedImage = IMG_Load( filename.c_str() );

return loadedImage;

}

So could someone please tell me how to correctly load the png alpha channel…& how to “manually” create a texture image as shown above.

Abhijit---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.