| 1 | {$i bgrasse.inc}
|
|---|
| 2 |
|
|---|
| 3 | var
|
|---|
| 4 | xLen: single; //horizontal length in pixels
|
|---|
| 5 | t: single; //initial horizontal position in [0..1]
|
|---|
| 6 | texVect: TPointF; //texture vector between start and end of line
|
|---|
| 7 | texPos: TPointF; //texture start position
|
|---|
| 8 | texStep: TPointF; //texture step
|
|---|
| 9 | intTexPos: packed record
|
|---|
| 10 | x,y: integer;
|
|---|
| 11 | end;
|
|---|
| 12 |
|
|---|
| 13 | //loop variables
|
|---|
| 14 | pdest: PBGRAPixel;
|
|---|
| 15 | i: LongInt;
|
|---|
| 16 |
|
|---|
| 17 | {$IFDEF PARAM_USELIGHTING}
|
|---|
| 18 | light,lightStep,lightDiff,lightAcc,lightMod: word;
|
|---|
| 19 | lightLen: integer;
|
|---|
| 20 |
|
|---|
| 21 | procedure NextLight; inline;
|
|---|
| 22 | begin
|
|---|
| 23 | light := (light+lightStep) and 65535;
|
|---|
| 24 | inc(lightAcc,lightDiff);
|
|---|
| 25 | if lightAcc >= lightMod then
|
|---|
| 26 | begin
|
|---|
| 27 | dec(lightAcc,lightMod);
|
|---|
| 28 | light := (light + 1) and 65535;
|
|---|
| 29 | end;
|
|---|
| 30 | end;
|
|---|
| 31 | {$ENDIF}
|
|---|
| 32 |
|
|---|
| 33 | begin
|
|---|
| 34 | xLen := info2.interX - info1.interX;
|
|---|
| 35 | t := ((ix1+0.5)-info1.interX)/xLen;
|
|---|
| 36 |
|
|---|
| 37 | texVect := info2.texCoord-info1.texCoord;
|
|---|
| 38 | texPos := info1.texCoord + texVect*t;
|
|---|
| 39 | texStep := texVect*(1/xLen);
|
|---|
| 40 |
|
|---|
| 41 | pdest := bmp.ScanLine[yb]+ix1;
|
|---|
| 42 |
|
|---|
| 43 | {$IFDEF PARAM_USELIGHTING}
|
|---|
| 44 | if ix2 = ix1 then
|
|---|
| 45 | begin
|
|---|
| 46 | light := (info1.lightness+info2.lightness) div 2;
|
|---|
| 47 | lightStep := 0;
|
|---|
| 48 | lightDiff := 0;
|
|---|
| 49 | lightMod := 1;
|
|---|
| 50 | end
|
|---|
| 51 | else
|
|---|
| 52 | begin
|
|---|
| 53 | light := info1.lightness;
|
|---|
| 54 | lightLen := info2.lightness-info1.lightness;
|
|---|
| 55 | if lightLen >= 0 then
|
|---|
| 56 | begin
|
|---|
| 57 | lightStep := lightLen div (ix2-ix1);
|
|---|
| 58 | lightMod := ix2-ix1;
|
|---|
| 59 | lightDiff := lightLen - lightStep*(ix2-ix1);
|
|---|
| 60 | end else
|
|---|
| 61 | begin
|
|---|
| 62 | lightStep := (-lightLen+(ix2-ix1-1)) div (ix2-ix1);
|
|---|
| 63 | lightMod := ix2-ix1;
|
|---|
| 64 | lightDiff := lightLen + lightStep*(ix2-ix1);
|
|---|
| 65 | lightStep := 65536 - lightStep;
|
|---|
| 66 | end;
|
|---|
| 67 | end;
|
|---|
| 68 | lightAcc := lightDiff div 2;
|
|---|
| 69 | {$ENDIF}
|
|---|
| 70 |
|
|---|
| 71 | {$IFDEF BGRASSE_AVAILABLE}
|
|---|
| 72 | if UseSSE then
|
|---|
| 73 | begin
|
|---|
| 74 | {$DEFINE PARAM_USESSE}
|
|---|
| 75 | if UseSSE2 then
|
|---|
| 76 | begin
|
|---|
| 77 | {$DEFINE PARAM_USESSE2}
|
|---|
| 78 | if WithInterpolation then
|
|---|
| 79 | begin
|
|---|
| 80 | {$DEFINE PARAM_USEINTERPOLATION}
|
|---|
| 81 | {$i lineartexscan2.inc}
|
|---|
| 82 | {$UNDEF PARAM_USEINTERPOLATION}
|
|---|
| 83 | end else
|
|---|
| 84 | begin
|
|---|
| 85 | {$i lineartexscan2.inc}
|
|---|
| 86 | end;
|
|---|
| 87 | {$UNDEF PARAM_USESSE2}
|
|---|
| 88 | end else
|
|---|
| 89 | begin
|
|---|
| 90 | if WithInterpolation then
|
|---|
| 91 | begin
|
|---|
| 92 | {$DEFINE PARAM_USEINTERPOLATION}
|
|---|
| 93 | {$i lineartexscan2.inc}
|
|---|
| 94 | {$UNDEF PARAM_USEINTERPOLATION}
|
|---|
| 95 | end else
|
|---|
| 96 | begin
|
|---|
| 97 | {$i lineartexscan2.inc}
|
|---|
| 98 | end;
|
|---|
| 99 | end;
|
|---|
| 100 | {$UNDEF PARAM_USESSE}
|
|---|
| 101 | end else
|
|---|
| 102 | {$ENDIF}
|
|---|
| 103 | if WithInterpolation then
|
|---|
| 104 | begin
|
|---|
| 105 | {$DEFINE PARAM_USEINTERPOLATION}
|
|---|
| 106 | {$i lineartexscan2.inc}
|
|---|
| 107 | {$UNDEF PARAM_USEINTERPOLATION}
|
|---|
| 108 | end else
|
|---|
| 109 | begin
|
|---|
| 110 | {$i lineartexscan2.inc}
|
|---|
| 111 | end;
|
|---|
| 112 | end;
|
|---|
| 113 | {$undef PARAM_USELIGHTING}
|
|---|