Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Transparent color in .bmp texture loading

  1. #1
    Guest

    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.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2004
    Location
    Los Angeles, CA, USA
    Posts
    216

    Re: Transparent color in .bmp texture loading

    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.)

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: Transparent color in .bmp texture loading

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •