I tried your idea and it worked. I replaced the inner loop with this
Code:
B := Round(RGB.B * 256);
G := Round(RGB.G * 256);
R := Round(RGB.R * 256);
Bd := Round(RGBdx.B * 256);
Gd := Round(RGBdx.G * 256);
Rd := Round(RGBdx.R * 256);
for x := ScanStart to ScanEnd do begin
RGBT.rgbtBlue := B shr 8;
RGBT.rgbtGreen := G shr 8;
RGBT.rgbtRed := R shr 8;
Scan[x] := RGBT;
Inc(B, Bd);
Inc(G, Gd);
Inc(R, Rd);
end;
R, G, B, Rd, Gd, Bd are all integers.
I tested it by drawing a large gouraud triangle 10000 times. The old routine took 17 seconds - the new routine took 14 seconds .
Thanks for your help
Peter
Bookmarks