OpenGL blending problem

Started by
29 comments, last by clearly 17 years, 11 months ago
i just tryed and when i did it red,green it was evrything was blended red or green
wierd//
when i did it white it didnt showed anything but white..
Advertisement
You do realise that when u are blending, u have to draw in depth order? That is the background must be drawn first and then the tank, so that the tank's transparent part blend with the background, because the blend function kind of work like CurrentColor = (1-alpha)CurrentColor + alpha*BackColor
No idea then. Maybe load up a pic of a render and the texture. Nevermind on that.

*edit again. Uhm you are drawing your background after you draw the tank. I just wasted all my time. Draw the background first, or enable depth testing. peace.

*edit again again. Damn you JackRhino :)

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

well if i put the background drawing first
its doing the same thing that did on the start
the tanks is under the background..
haha, enable depth testing also won't work, u must draw in depth order, because even if depth testing is enabled, for example u draw a window in front, ok it blends with an empty background. Now u draw a tree behind the window. The window is not going to be redrawn and reblend with the tree behind, so the window will have 'incorrect' blending. Thou it is correct in the sense it has blend correctly with the previous background. This will result in the tree not being shown through the window
This depends on your viewpoint, are u sure the the -negative z axis is pointing towards u? If u have enable depth testing and u got the axis direction wrong, even if u draw the background first, but the background is drawn in front of the tank, u will continue to have the problem as the background will cover the tank.
so what do i need to do ?
Yea wasnt thinking Rhino man. What you need to do is switch your drawing operations...didn't u understand from what we said, your drawing a tank first, then placing a background over it......reverse the order.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

dude i already TOLD U
that i did IT
but its not changeing anything!
the background is covering the tank anyway!
LOOK:
http://members.lycos.co.uk/clearly/1.JPG
Turn off blending when drawing the background, then turn on blending and draw the tank.

If you wanted to get rid of just the black area around the tank you will have either use a second texture as a mask or use a texture format with an alpha channel.

If you are using the mask texture method you need to create a copy of the tank texture and colour all the pixels of the tank you want visible with black and all the transparent areas with white. (any greys will apear semi-transparent)

To render with the mask you need to do


disable blending
draw background

glBlendFunc(GL_DST_COLOR,GL_ZERO);

enable blending
draw tank mask image

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

draw tank image

Hope it helps.

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

This topic is closed to new replies.

Advertisement