Back Transparency

Started by
3 comments, last by Psycho1 22 years, 5 months ago
Is their a way to make bmp images have a transparent background? Edited by - Psycho1 on November 1, 2001 11:40:28 AM
Advertisement
Hmmm... As far as I am aware there is no way to make bitmaps with an alpha channel though there are 2 ways to make a background colour transparent:

1) The easier way. Use a mask (NeHe: #20) to mask out the background.

2) The harder way When loading in the bitmap pixel data, check each pixel in the bitmap to see whether it is the background colour (presumably black = 0), if it is then you set the pixel data in a new array which is 32 bits per pixel and set the alpha component to transparent (0), otherwise set the alpha component to opaque (255).

loop through bitmap pixel array
if (bitmap[index] == background_color)
texture_pixels[index] = RGBA(0, 0, 0, 0);
else
texture_pixels[index] = RGBA(blah..., 255);
loop

I hope that shows you what I mean! (Kind of...) Well - that should kinda give yer the idea

Hope that helps!
quote:When loading in the bitmap pixel data, check each pixel in the bitmap to see whether it is the background colour (presumably black = 0

It''s actually better to use some weird color that you''re not very likely to use in your charachters or textures or whatever. Like pink. That''s not a very common color in games
-----------------------------Reporter: Are they slow-moving, chief?Sheriff: Yeah, they're dead. They're all messed up.-Night of the living dead
Ok, that works, but one other problem. If i want to show a normal shape, and it doesnt have a texture, it wont show after glBlendFunc(); has been used..
is their a way to set the blend func to nothing? x_X;
> is their a way to set the blend func to nothing?

Call

glDisable(GL_BLEND); 


but don''t forget to call

glEnable(GL_BLEND); 


before drawing transparent things.

PS: Same goes for drawing non-textured things after textured things

This topic is closed to new replies.

Advertisement