Transparent color in .bmp texture loading

In DirectX, when loading a .bmp texture, it’s possible to specify a transparent RGB color. Is there any similar texture loading method in OpenGL? If so, source code or a tutorial would be greatly appreciated.

I’m currently using .tga files to allow for transparencies, but a color-coded .bmp would be much easier to work with.

I thank you in advance.

I’m not sure how you are loading your BMPs, but you can always just copy the WxHx3 bitmap to a WxHx4 bitmap and set the alpha channel accordingly.

One thing to keep in mind: if you are interpolating the texture, you can have the transparent color bleed out. For example, if your transparent color is (1,0,1), this would become (1,0,1,0). If the texel next to it is (0,0,0,1), the sample between texels will be (0.5, 0, 0.5, 0.5), which isn’t what you want. For that reason you probably want to map your key color to (0,0,0,0). (Or you can be more clever and map it to the nearest non-transparent color but with zero alpha.)

TGA’s are easier to work with, since you don’t have to use up a color to get a transparentcy.
The only problem with using a single BMP and a color from it as a transparentcy color is that that color is no longer able to be used.

but I have seen people use two BMP files to create a transparentcy.
You can first create your BMP then create a seconde BMP with it as the transparentcy mask. You load the both BMP’s then combine them to create a RGBA texture.