Archived

This topic is now archived and is closed to further replies.

Psycho1

Back Transparency

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
> 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

Share this post


Link to post
Share on other sites