Advertisement

White bars

Started by April 25, 2001 09:13 PM
9 comments, last by Sarashinai 23 years, 7 months ago
Okay. I''ve got a BMP texture, it''s 64x64 but that actual colored part is 64x50. In Photoshop I made everything that wasn''t part of the image transparent. But when I place it on the quad white bars appear on the sides. How do I make it just draw the image? Thanks.
How do you mean "made it transparent" ? BMP doesn''t have any alpha channel what I know of..



return 1;
Advertisement
You can set a bmp color to black for transparacy if your using, what is it... glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR)

course, you loose all texture color info. There has to be a better way. That''s what I keep telling my self.

As for the white bars, sounds like your texture border is a bit large. I''m no expert here though, hope someone who''s sure shows up for you. Do you have this problem with one or all textures?

-Alex
quote: Original post by Anonymous Poster

You can set a bmp color to black for transparacy if your using, what is it... glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR)



i use glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA)
can any1 tell me the difference between these?



life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
with glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA)
none of the black is gonna show up on the screen BUT the only colour that will show up fully is white ie (1,1,1)


http://members.xoom.com/myBollux
Your single best bet in transparencies is using targa TGA files. They, along with several other formats, contain an alpha channel that will allow you to mask textures. This is what I use to make items like non standard shaped textures, fences, chains, window frames, and fane grates.

Using bitmaps is going to force you to use blending of some kind, which in turn will alter your color base in some form or another. TGA files are easy to load and work with, and transparency is enabled with one GL function.

Jason

Advertisement
That sounds like a great solution DeschutesCore. I just have two questions.

1. How do you make Photoshop save the transparency?

2. How do you load it in OpenGL? Can you use auxDIBImageLoad?

Edit: If you don't use Photoshop, what program do you use and how do you make that program save the transparency.

Edited by - Sarashinai on April 26, 2001 8:52:53 AM
quote: Original post by zedzeek

with glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA)
none of the black is gonna show up on the screen BUT the only colour that will show up fully is white ie (1,1,1)


http://members.xoom.com/myBollux


isn''t that what
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR)
does?



life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
"1. How do you make Photoshop save the transparency?"

I use Paint Shop Pro 7 to create all of my TGA files. What I do is fill any area to be transparent with white or gray, then use the selection tool to create a selection of all areas with shift-left click. Once the selection is complete, I invert the selection and save it to an alpha channel. Photoshop does handle alpha, ut it''s buried in the menus, it should be available on the layers palette as well.

Please remember to save all tga files UNCOMPRESSED files. Unless, of course, you have a decompression scheme already in place with your loader unit.

"2. How do you load it in OpenGL? Can you use auxDIBImageLoad?"

I use Delphi, so our mileage will vary, but I use FileRead to load the data, then parse the headers just like a DIB and use

ReadFile(tgafile, pData^, imageSize, ReadBytes, nil);

From there I flip the red and green bits with a simple loop and move on to loading the DIB with:

if (BPP = 32) then
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, pData)
else
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pData);

I use this code for bitmap and tga.

Good luck,
Jason



Ok, a quick explaination.

GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA: standard transperancy. Black areas are shown.


GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR: color levels are lost. Only intensity levels. Different levels of brightness determine how see through it is. You can set it to any color. Black areas, being 0,0,0 are completely transperant. So when using the SRC_COLOR destination, you basically transform all bmp color channels into a joint aplha channel. Good for some perpouses, at least for mine. (-:

-Alex

Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"

This topic is closed to new replies.

Advertisement