I'm having some trouble loading a 32 bit .bmp image in my opengl game. So far i can load and display 24 bit perfectly. I now want to load a bit map with portions of its texture being transparent or invisible. 

This function has no problems with 24 bit. but 32 bit with alpha channel .bmp seem to distort the colors and cause transparently in unintended places. 

```
Texture LoadTexture( const char * filename, int width, int height, bool alpha) 
    {
        GLuint texture;
        GLuint* data;
        FILE* file;

        fopen_s(&file, filename, "rb");  
        if(!file)
        {
            std::cout << filename <<": Load Texture Fail!\n";
            exit(0);
        }

        data = new GLuint[width * height];

        fread( data, width * height * sizeof(GLuint), 1, file ); 
        fclose(file);

        glGenTextures( 1, &texture );
        glBindTexture( GL_TEXTURE_2D, texture);
        glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

        if(alpha) //for .bmp 32 bit
        {
            glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 
            glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        }
        else //for .bmp 24 bit
        {
            glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 
            glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_BGR, GL_UNSIGNED_BYTE, data);
        }

        std::cout<<"Texture: "<<filename<< " loaded"<<std::endl;
        delete data;

        return Texture(texture); 
    }

```

In Game Texture, drawn on a flat plane
![enter image description here](https://i.stack.imgur.com/oAb53.png)

this might look like its working but the 0xff00ff color is the one that should be transparent. and if i reverse the alpha channel in photoshop the result is the same the iner sphere is always transparent. 

i also enabled:

```
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

```

there is no problems with transparency the problems seems to be with loading the bitmap with an alpha channel. also all bit maps that I load seem to be off a bit to the right. Just wondering if there was a reason for this?