Transparnecy equations

i’m going to be doing some transparencies and i’d like to use putpixel
and plot the pixels myself. how do i figure out what color the pixel
should be? i grab the color that’s under it, know the color to go on
top, but what’s the (from what i understand it, very simple) math to
combine those two colors and also have a variable in their for the
opacity?

anybody want to hand out a brief explaination of the math? i’m assuming
it’s remarkably simple. lol–

“Christopher Thielen” wrote in message
news:mailman.1016154011.28054.sdl at libsdl.org

i’m going to be doing some transparencies and i’d like to use
putpixel
and plot the pixels myself.

You have got to be kidding.

how do i figure out what color the pixel
should be? i grab the color that’s under it, know the color to go on
top, but what’s the (from what i understand it, very simple) math to
combine those two colors and also have a variable in their for the
opacity?

new_dest = src_alpha * src + (1 - src_alpha) * dest

Do this for all three components (RGB). src_alpha is in the range of
0.0 to 1.0. Don’t use actual floating point math.–
Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com

At 18:21 14.03.2002 -0700, you wrote:

“Christopher Thielen” wrote in message
news:mailman.1016154011.28054.sdl at libsdl.org

i’m going to be doing some transparencies and i’d like to use
putpixel
and plot the pixels myself.

You have got to be kidding.

He surely seems to …

how do i figure out what color the pixel
should be? i grab the color that’s under it, know the color to go on
top, but what’s the (from what i understand it, very simple) math to
combine those two colors and also have a variable in their for the
opacity?

new_dest = src_alpha * src + (1 - src_alpha) * dest

for OpenGL this equation is
glBlendFunc(blendfunc[0],blendfunc[1]);
new_dest = BlendFunc[0] * src + BlendFunc[1] * dest;

Do this for all three components (RGB). src_alpha is in the range of
0.0 to 1.0. Don’t use actual floating point math.

possible values for blendfunc:
GL_SRC_ALPHA,
GL_DST_ALPHA,
GL_ONE_MINUS_SRC_ALPHA,
GL_ONE_MINUS_DST_ALPHA,
and then you can (I think) replace ALPHA with COLOR.

The only thing with OpenGL is, that it computes this mass of calculations
(for each Pixel drawn …) via Hardware, in some optimized way …
hopefully this makes you realize, how little you may draw and how fast your
computer may be to display something in a certain framerate, when you
calculate this on your own …>–

Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl