Ignore:
Timestamp:
Apr 9, 2015, 9:58:36 PM (9 years ago)
Author:
chronos
Message:
  • Fixed: Use csOpaque control style also to Image, PaintBox and OpenGLControl.
  • Modified: Change size of test frame with SpinEdits as delayed using timer.
  • Updated: BRGABitmap package to version 8.1.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/polyaliaspersp.inc

    r452 r472  
    33
    44{ TPolygonPerspectiveTextureMappingInfo }
     5
     6procedure TPolygonPerspectiveTextureMappingInfo.SetIntersectionValues(
     7  AInter: TIntersectionInfo; AInterX: Single; AWinding, ANumSegment: integer;
     8  dy: single; AData: pointer);
     9var info: PPerspectiveTextureInfo;
     10begin
     11  AInter.SetValues(AInterX,AWinding,ANumSegment);
     12  info := PPerspectiveTextureInfo(AData);
     13  TPerspectiveTextureMappingIntersectionInfo(AInter).coordInvZ := dy*info^.InvZSlope + info^.InvZ;
     14  TPerspectiveTextureMappingIntersectionInfo(AInter).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;
     15  if FLightnesses<>nil then
     16    TPerspectiveTextureMappingIntersectionInfo(AInter).lightness := round(info^.lightness + info^.lightnessSlope*dy)
     17  else
     18    TPerspectiveTextureMappingIntersectionInfo(AInter).lightness := 32768;
     19end;
    520
    621constructor TPolygonPerspectiveTextureMappingInfo.Create(
     
    108123begin
    109124  Result:= TPerspectiveTextureMappingIntersectionInfo.Create;
    110 end;
    111 
    112 procedure TPolygonPerspectiveTextureMappingInfo.ComputeIntersection(cury: single;
    113       var inter: ArrayOfTIntersectionInfo; var nbInter: integer);
    114 var
    115   j: integer;
    116   dy: single;
    117   info: PPerspectiveTextureInfo;
    118 begin
    119   if length(FSlices)=0 then exit;
    120 
    121   while (cury < FSlices[FCurSlice].y1) and (FCurSlice > 0) do dec(FCurSlice);
    122   while (cury > FSlices[FCurSlice].y2) and (FCurSlice < high(FSlices)) do inc(FCurSlice);
    123   with FSlices[FCurSlice] do
    124   if (cury >= y1) and (cury <= y2) then
    125   begin
    126     for j := 0 to nbSegments-1 do
    127     begin
    128       dy := cury - segments[j].y1;
    129       inter[nbinter].interX := dy * segments[j].slope + segments[j].x1;
    130       inter[nbinter].winding := segments[j].winding;
    131       info := PPerspectiveTextureInfo(segments[j].data);
    132       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).coordInvZ := dy*info^.InvZSlope + info^.InvZ;
    133       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;
    134       if FLightnesses<>nil then
    135         TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).lightness := round(info^.lightness + info^.lightnessSlope*dy)
    136       else
    137         TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).lightness := 32768;
    138       Inc(nbinter);
    139     end;
    140   end;
    141125end;
    142126
     
    495479{ TPolygonPerspectiveMappingShaderInfo }
    496480
     481procedure TPolygonPerspectiveMappingShaderInfo.SetIntersectionValues(
     482  AInter: TIntersectionInfo; AInterX: Single; AWinding, ANumSegment: integer;
     483  dy: single; AData: pointer);
     484var info : PPerspectiveTextureInfo;
     485begin
     486  AInter.SetValues(AInterX,AWinding,ANumSegment);
     487  info := PPerspectiveTextureInfo(AData);
     488  TPerspectiveTextureMappingIntersectionInfo(AInter).coordInvZ := dy*info^.InvZSlope + info^.InvZ;
     489  TPerspectiveTextureMappingIntersectionInfo(AInter).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;
     490  TPerspectiveTextureMappingIntersectionInfo(AInter).Position3D := info^.Position3D + info^.Position3DSlope*dy;
     491  TPerspectiveTextureMappingIntersectionInfo(AInter).Normal3D := info^.Normal3D + info^.Normal3DSlope*dy;
     492end;
     493
    497494constructor TPolygonPerspectiveMappingShaderInfo.Create(
    498495  const points: array of TPointF; const points3D: array of TPoint3D;
     
    608605end;
    609606
    610 procedure TPolygonPerspectiveMappingShaderInfo.ComputeIntersection(
    611   cury: single; var inter: ArrayOfTIntersectionInfo; var nbInter: integer);
    612 var
    613   j: integer;
    614   dy: single;
    615   info: PPerspectiveTextureInfo;
    616 begin
    617   if length(FSlices)=0 then exit;
    618 
    619   while (cury < FSlices[FCurSlice].y1) and (FCurSlice > 0) do dec(FCurSlice);
    620   while (cury > FSlices[FCurSlice].y2) and (FCurSlice < high(FSlices)) do inc(FCurSlice);
    621   with FSlices[FCurSlice] do
    622   if (cury >= y1) and (cury <= y2) then
    623   begin
    624     for j := 0 to nbSegments-1 do
    625     begin
    626       dy := cury - segments[j].y1;
    627       inter[nbinter].interX := dy * segments[j].slope + segments[j].x1;
    628       inter[nbinter].winding := segments[j].winding;
    629       info := PPerspectiveTextureInfo(segments[j].data);
    630       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).coordInvZ := dy*info^.InvZSlope + info^.InvZ;
    631       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;
    632       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).Position3D := info^.Position3D + info^.Position3DSlope*dy;
    633       TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).Normal3D := info^.Normal3D + info^.Normal3DSlope*dy;
    634       Inc(nbinter);
    635     end;
    636   end;
    637 end;
    638 
Note: See TracChangeset for help on using the changeset viewer.