hedgewars/uRender.pas
changeset 10312 eda8d563f677
parent 10311 30b5fab302f6
child 10318 c2e81eea375f
equal deleted inserted replaced
10311:30b5fab302f6 10312:eda8d563f677
   631 procedure UpdateViewLimits();
   631 procedure UpdateViewLimits();
   632 var tmp: real;
   632 var tmp: real;
   633 begin
   633 begin
   634     // cScaleFactor is 2.0 on "no zoom"
   634     // cScaleFactor is 2.0 on "no zoom"
   635     tmp:= cScreenWidth / cScaleFactor;
   635     tmp:= cScreenWidth / cScaleFactor;
   636     ViewRightX:= round(tmp); // ceil could make more sense
   636     ViewRightX:= 1 + round(tmp);
   637     ViewLeftX:= round(-tmp); // floor could make more sense
   637     ViewLeftX:= round(-tmp);
   638     tmp:= cScreenHeight / cScaleFactor;
   638     tmp:= cScreenHeight / cScaleFactor;
   639     ViewBottomY:= round(tmp) + cScreenHeight div 2; // ceil could make more sense
   639     ViewBottomY:= 1 + round(tmp) + cScreenHeight div 2;
   640     ViewTopY:= round(-tmp) + cScreenHeight div 2; // floor could make more sense
   640     ViewTopY:= round(-tmp) + cScreenHeight div 2;
   641 
   641 
   642     // visual debugging fun :D
   642     // visual debugging fun :D
   643     if cViewLimitsDebug then
   643     if cViewLimitsDebug then
   644         begin
   644         begin
   645         // some margin on each side
   645         // some margin on each side
   917 end;
   917 end;
   918 
   918 
   919 procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
   919 procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
   920 begin
   920 begin
   921 
   921 
       
   922 if Angle <> 0  then
       
   923     begin
       
   924     // sized doubled because the sprite might occupy up to 1.4 * of it's
       
   925     // original size in each dimension, because it is rotated
       
   926     if isDxAreaOffscreen(X - SpritesData[Sprite].Width, 2 * SpritesData[Sprite].Width) <> 0 then
       
   927         exit;
       
   928     if isDYAreaOffscreen(Y - SpritesData[Sprite].Height, 2 * SpritesData[Sprite].Height) <> 0 then
       
   929         exit;
       
   930     end
       
   931 else
       
   932     begin
       
   933     if isDxAreaOffscreen(X - SpritesData[Sprite].Width div 2, SpritesData[Sprite].Width) <> 0 then
       
   934         exit;
       
   935     if isDYAreaOffscreen(Y - SpritesData[Sprite].Height div 2 , SpritesData[Sprite].Height) <> 0 then
       
   936         exit;
       
   937     end;
       
   938 
       
   939 
   922 openglPushMatrix;
   940 openglPushMatrix;
   923 openglTranslatef(X, Y, 0);
   941 openglTranslatef(X, Y, 0);
   924 
   942 
       
   943 // mirror
   925 if Dir < 0 then
   944 if Dir < 0 then
   926     begin
       
   927     openglRotatef(Angle, 0, 0, -1);
       
   928     openglScalef(-1.0, 1.0, 1.0);
   945     openglScalef(-1.0, 1.0, 1.0);
   929     end
   946 
   930 else
   947 // apply angle after (conditional) mirroring
   931     openglRotatef(Angle, 0, 0,  1);
   948 if Angle <> 0  then
       
   949     openglRotatef(Angle, 0, 0, 1);
   932 
   950 
   933 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
   951 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
   934 
   952 
   935 openglPopMatrix;
   953 openglPopMatrix;
   936 
   954