anchor.diff:    SwapInt(bmp[i*sw+k],bmp[((sh-1)-i)*sw+k]);
   
     mkbmp := TBitmap.Create;
  -  mkbmp.Handle:=CreateBitmap(sw,sh,1,32,@bmp[0]);
  +  mkbmp.Handle := CreateBitmap(sw,sh,1,32,@bmp[0]);
   
     jpg := TJpegImage.Create;
     jpg.assign(mkbmp);
  
positive.code:   end else begin
      ShiftX:=RXData[1].Pivot[ID].x/CELL_SIZE_PX;
      ShiftY:=(RXData[1].Pivot[ID].y+RXData[1].Size[ID].Y)/CELL_SIZE_PX-fTerrain.Land[pY,pX].Height/CELL_HEIGHT_DIV;
      AddSpriteToList(1,ID,pX+ShiftX,pY+ShiftY,pX,pY,true);
      {RenderDot(pX,pY);
      glRasterPos2f(pX-1+0.1,pY-1+0.1);
      glPrint(inttostr(Index)+':'+inttostr(ID));}
  
negative.code: {$ENDIF}
  
  type
    TRenderList = class
    private
      RenderCount:word;
      RO:array of word; //RenderOrder
      RenderList:array of record
        Loc,Obj:TKMPointF;
        RX:byte;
        ID:word;
        NewInst,IsUnit:boolean;
        Team:cardinal;
        AlphaStep:single; //Only appliable to HouseBuild
        FOWvalue:byte; // Fog of War thickness
      end;
  
      fStat_Sprites:integer; //Total sprites in queue
      fStat_Sprites2:integer;//Rendered sprites
      procedure ClipRenderList;
      procedure SortRenderList;
    public
      constructor Create;
      destructor Destroy; override;
      procedure AddSprite(aRX:byte; aID:word; pX,pY,oX,oY:single; aNew:boolean; const aTeam:cardinal=$00000000; const Step:single=-1; aIsUnit:boolean=false);
      property Stat_Sprites:integer read fStat_Sprites;
      property Stat_Sprites2:integer read fStat_Sprites2;
      procedure Render;
    end;
  
    TRender = class
    private
      h_DC: HDC;
      h_RC: HGLRC;
      fOpenGL_Vendor, fOpenGL_Renderer, fOpenGL_Version:string;
      TextG:GLuint; //Shading gradient
      TextT:GLuint; //Tiles
      TextW:array[1..8]of GLuint; //Water
      TextS:array[1..3]of GLuint; //Swamps
      TextF:array[1..5]of GLuint; //WaterFalls
      fScreenX, fScreenY:word;
      rPitch,rHeading,rBank:integer;
      fRenderList: TRenderList;
  
      procedure RenderDot(pX,pY:single; Size:single = 0.05);
      procedure RenderDotOnTile(pX,pY:single);
      procedure RenderLine(x1,y1,x2,y2:single);
      procedure RenderQuad(pX,pY:integer);
      procedure RenderTile(Index:byte; pX,pY,Rot:integer);
      procedure RenderSprite(RX:byte; ID:word; pX,pY:single; Col:TColor4; aFOW:byte; HighlightRed: boolean=false);
      procedure RenderSpriteAlphaTest(RX:byte; ID:word; Param:single; pX,pY:single; aFOW:byte);
      procedure RenderTerrainMarkup(Index:integer; pX,pY:integer);
      procedure RenderTerrainBorder(Border:TBorderType; Pos:TKMDirection; pX,pY:integer);
      procedure RenderCursorWireQuad(P:TKMPoint; Col:TColor4);
      procedure RenderCursorBuildIcon(P:TKMPoint; id:integer=479);
      procedure RenderCursorWireHousePlan(P:TKMPoint; aHouseType:THouseType);
      procedure RenderCursorHighlights;
      procedure RenderBrightness(Value:byte);
    public
      constructor Create(RenderFrame:HWND; aVSync:boolean);
      destructor Destroy; override;
  
      procedure LoadTileSet;
      procedure SetRotation(aH,aP,aB:integer);
      procedure Resize(Width,Height:integer; aRenderMode:TRenderMode);
      function Stat_Sprites:integer;
      function Stat_Sprites2:integer;
      procedure Render;
      {$IFDEF WDC}
      procedure DoPrintScreen(FileName:string);
      {$ENDIF}
      procedure RenderTerrain(x1,x2,y1,y2,AnimStep:integer);
      procedure RenderTerrainFieldBorders(x1,x2,y1,y2:integer);
      procedure RenderTerrainObjects(x1,x2,y1,y2,AnimStep:integer);
      procedure RenderDebugCircle(x,y,rad:single; Fill,Line:TColor4);
      procedure RenderDebugLine(x1,y1,x2,y2:single);
      procedure RenderDebugProjectile(x1,y1,x2,y2:single);
      procedure RenderDebugWires(x1,x2,y1,y2:integer);
      procedure RenderDebugPassability(x1,x2,y1,y2:integer);
      procedure RenderDebugUnitPointers(pX,pY:single; Count:integer);
      procedure RenderDebugUnitMoves(x1,x2,y1,y2:integer);
      procedure RenderDebugUnitRoute(NodeList:TKMPointList; Pos:integer; aUnitType:byte);
      procedure RenderDebugQuad(pX,pY:integer);
      procedure RenderDebugText(pX,pY:integer; aText:string; aCol:TColor4);
      procedure RenderProjectile(aProj:TProjectileType; pX,pY:single; Flight:single; Dir:TKMDirection=dir_NA);
      procedure RenderObjectOrQuad(Index,AnimStep,pX,pY:integer; DoImmediateRender:boolean=false; Deleting:boolean=false);
      procedure RenderObject(Index,AnimStep,pX,pY:integer; DoImmediateRender:boolean=false; Deleting:boolean=false);
      procedure RenderObjectQuad(Index:integer; AnimStep,pX,pY:integer; IsDouble:boolean; DoImmediateRender:boolean=false; Deleting:boolean=false);
      procedure RenderHouseBuild(Index:THouseType; Loc:TKMPoint);
      procedure RenderHouseBuildSupply(Index:THouseType; Wood,Stone:byte; Loc:TKMPoint);
      procedure RenderHouseWood(Index:THouseType; Step:single; Loc:TKMPoint);
      procedure RenderHouseStone(Index:THouseType; Step:single; Loc:TKMPoint);
      procedure RenderHouseWork(Index:THouseType; AnimType,AnimStep:cardinal; Loc:TKMPoint; FlagColor:TColor4);
      procedure RenderHouseSupply(Index:THouseType; const R1,R2:array of byte; Loc:TKMPoint);
      procedure RenderHouseStableBeasts(Index:THouseType; BeastID,BeastAge,AnimStep:integer; Loc:TKMPoint);
      procedure RenderUnit(UnitID,ActID,DirID,StepID:integer; pX,pY:single; FlagColor:TColor4; NewInst:boolean; DoImmediateRender:boolean=false; Deleting:boolean=false);
      procedure RenderUnitCarry(CarryID,DirID,StepID:integer; pX,pY:single);
      procedure RenderUnitThought(Thought:TUnitThought; pX,pY:single);
      procedure RenderUnitFlag(UnitID,ActID,DirID,StepID:integer; pX,pY:single; FlagColor:TColor4; UnitX,UnitY:single; NewInst:boolean);
      procedure RenderUnitWithDefaultArm(UnitID,ActID,DirID,StepID:integer; pX,pY:single; FlagColor:TColor4; NewInst:boolean; DoImmediateRender:boolean=false; Deleting:boolean=false);
      property RendererVersion:string read fOpenGL_Version;
    end;
  
      
  var
  