glBlendFunc(GL_SRC_ALPHA,GL_ONE);

Started by
6 comments, last by trager 20 years, 3 months ago
how come when I use glBlendFunc(GL_SRC_ALPHA,GL_ONE); the colour of the object comes through the texture? Is there a way around this?
Advertisement
What do you mean by the color of the object, like the color you set with glColor4x(....)?, texels are always drawn as color
(tr*or+tg*og+tb*ob+ta*oa), where tx stands for texture x and o for object.

[edited by - Tree Penguin on January 17, 2004 7:35:27 AM]
yup,

so if you use color4f(1,1,1,1) the background would be white and it seems to make the texture really bright for some reason.

If you set it to red the texture takes on a red hue most annoying.
texels are always drawn as color
(tr*or+tg*og+tb*ob+ta*oa), where tx stands for texture x and o for object.


means close to nothing to me
got what you mean by (tr*or+tg*og+tb*ob+ta*oa) doesn''t seem to apply in the case of semi transparent objects on top of each other.

Think sprites on a background.
Set the texture env mode to GL_REPLACE instead of GL_MODULATE.
i.e. make a call to

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
No luck with that james. It disabled blending and quite possibly made the original problem worse.

I think i need to describe what I''m trying to do



I have a 2d game with a simple menu.
The menu text is made from bitmaps.
The bitmaps have a few nearly black pixels around the edges.
I want to drop these and glBlendFunc(GL_SRC_ALPHA,GL_ONE); does that
I also want to be able to fade the text slighlty when it isnt selected.


I can get all of this to happen but when the menu items are drawn over the background they seem to get very bright.

When there is no background it all works perfectly.
Any ideas on how to solve this?


Ooops, what was I thinking!

Perhaps what you should be using is alpha testing i.e. reject the pixels where alpha is above/below some threshold value. This then leaves you with the blend function to control how much the colour gets blended with the existing scene, to allow you to control the ''intensity'' of the output

This topic is closed to new replies.

Advertisement