glEnable(GL_BLEND);
glColor4f(r, g, b, a);
render();
glColor4f(1.0, 1.0, 1.0, 1.0);
glDisable(GL_BLEND);
OpenGL blending process
I thought there would be a lot more information about this topic. Maybe I'm just looking in all the wrong places, but I cannot find any information about the functions necessary for blending.
What I'm doing right now is:
This is blending how I want when I do this one time, but the next texture I render with this process screws everything up. So I'm assuming that I need to do something more at the end, but I cannot seem to find what I should do. Can anyone help?
Thank you.
You can't render like that because the second thing that draws will overwrite whatever is in the colour buffer.
What you need to do is to do something like
What you need to do is to do something like
glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);//DrawFloorglColor4f(1.0,1.0,1.0, 1.0f);renderFloor();//renderItem//Render Slightly Transparent ObjectglColor4f(1.0,1.0,0.0,0.4f);renderObject();
I'm not sure what you are suggesting? I'm not using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); because this deals particularly with text, and it makes it more difficult to read when I add that. Also, why is there no RGBA? I want to blend it with a particular color. Finally, what is floor?
Quote:Original post by yahnPlease be more accurate. If you ask a generic question you'll get a generic (and generally useless) answer.
This is blending how I want when I do this one time, but the next texture I render with this process screws everything up.
Generally blending will need a special back-to-front sort which I believe isn't going on. Whatever your result looks ok or not is a matter of the exact dataset being used.
What do you mean by "render the next texture"? If you're multipassing, you'll likely have to play a bit with Z.
Quote:Original post by NeutrinohunterIt should if the Z is left untouched... but I fear it isn't.
You can't render like that because the second thing that draws will overwrite whatever is in the colour buffer.
I agree however he should rethink his draw order.
Quote:Original post by yahnSure it does, you're fetching alpha for it. If you're using textured quads the alpha tipically comes from the texture and not from geometry... This is why there's no RGBA. Besides you shouldn't use immediate mode you should at least resist from using them that way.
I'm not sure what you are suggesting? I'm not using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); because this deals particularly with text, and it makes it more difficult to read when I add that.
Quote:Original post by yahnMaybe you need the constant blend color? I've never really used it much but I believe it could be it.
I want to blend it with a particular color.
Quote:Original post by yahnI suppose it's an example of something which provides a background to your blending.
Finally, what is floor?
I'm not changing the Z coords. Basically, I'm trying to create a function that can render a texture blended with a color. For example, I have a string stored in a texture that I want to be able to render as red or blue. What is the process of functions I need to call?
That renders the texture at a lower alpha without changing it's color. However, it is not causing the color buffer error from before. How do I get it to actually render it red?
glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glColor4f(1.0, 1.0, 1.0, 1.0f); // render the object once normallyrender();glColor4f(1.0, 0.0, 0.0, 0.4f); // render the object redrender();
That renders the texture at a lower alpha without changing it's color. However, it is not causing the color buffer error from before. How do I get it to actually render it red?
if it is of any help, here is a java programm that visualizes all the blendmodes available in opengl.
http://www.embege.com/blendinspect/
http://www.embege.com/blendinspect/
Quote:Original post by yahnIn that case you most likely don't want to use blending at all. Simply setting the texture environment mode to GL_MODULATE (the default) and then changing the primary color (glColor3f) should do what you want. That will multiply the texture's color by the primary color, so if the texture is white (1,1,1) and you set the primary color to cyan (0,1,1), the resulting color will be cyan as well.
...
Basically, I'm trying to create a function that can render a texture blended with a color. For example, I have a string stored in a texture that I want to be able to render as red or blue.
...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement