Hi,
ich versuche gerade zu verstehen was die Blendfunktion in
OpenGL glBlendFunc(GL_SRC_ALPHA, GL_ONE); anders macht als meine Softwareroutine:
Delphi-Quellcode:
function blend_additive(a, b: cardinal): cardinal;
var
a2, b2, carry, r: cardinal;
begin
// Mask of high bits
a2 := a and $7F7F7F7F;
b2 := b and $7F7F7F7F;
r := a2 + b2; // Do addition of most bits
// Now saturate
// Check if at least two out of the three high bits are set
carry := ((a and b and r) or (not(a xor b xor r) and ((a or b) or r))) and
$80808080;
// Convert 0x80 to 0xFF
carry := carry or (carry - (carry shr 7));
// Put back any high bits taken out
carry := carry or ((a or b) and $80808080);
result := r or carry;
end;
Ich möchte gerne das selbe in einem Pixelbuffer ohne
OpenGL realisieren, aber irgendwie gelingt mir das nicht. Hat jemand eine Idee?