[SDL] Combining per-pixel and per-surface alpha

Rainer Deyke root at rainerdeyke.com
Mon Jan 7 20:06:01 PST 2002


"David Olofson" <david.olofson at reologica.se> wrote in message
news:mailman.1010436783.18891.sdl at libsdl.org...
| Well, it would be a nice feature to have, but 3 or 4
|  multiplications and
| the same number of shifts extra per pixel (plus the extra shuffling
| around between registers for crap CPUs like x86) will result
|  in quite a
| performance hit - and alpha blending is slow enough as it is.

Actually only one multiplication and one divide is required (where the
divide can be replaced by a shift with some loss of quality):

  combined_alpha = (surface_alpha * pixel_alpha) / 255;


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the SDL mailing list