hedgewars/uRender.pas
changeset 15056 a315927a44b2
parent 14721 89dd60565041
child 15205 e7d7fe9f20e1
equal deleted inserted replaced
15055:981f16edea02 15056:a315927a44b2
    32 procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
    32 procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
    33 procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
    33 procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
    34 procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
    34 procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
    35 procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
    35 procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
    36 procedure DrawSpriteRotatedF    (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
    36 procedure DrawSpriteRotatedF    (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
       
    37 procedure DrawSpriteRotatedFReal(Sprite: TSprite; X, Y: Real; Frame, Dir: LongInt; Angle: real);
    37 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
    38 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
    38 
    39 
    39 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
    40 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
    40 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
    41 procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
    41 procedure DrawTexture2          (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
    42 procedure DrawTexture2          (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
  1150 procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
  1151 procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
  1151 begin
  1152 begin
  1152 
  1153 
  1153 if Angle <> 0  then
  1154 if Angle <> 0  then
  1154     begin
  1155     begin
  1155     // Check the bounding circle 
  1156     // Check the bounding circle
  1156     if isCircleOffscreen(X, Y, (sqr(SpritesData[Sprite].Width) + sqr(SpritesData[Sprite].Height)) div 4) then
  1157     if isCircleOffscreen(X, Y, (sqr(SpritesData[Sprite].Width) + sqr(SpritesData[Sprite].Height)) div 4) then
  1157         exit;
  1158         exit;
  1158     end
  1159     end
  1159 else
  1160 else
  1160     begin
  1161     begin
  1181 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1182 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1182 
  1183 
  1183 openglPopMatrix;
  1184 openglPopMatrix;
  1184 
  1185 
  1185 UpdateModelviewProjection;
  1186 UpdateModelviewProjection;
       
  1187 
       
  1188 end;
       
  1189 
       
  1190 procedure DrawSpriteRotatedFReal(Sprite: TSprite; X, Y: Real; Frame, Dir: LongInt; Angle: real);
       
  1191 begin
       
  1192 
       
  1193     if Angle <> 0  then
       
  1194     begin
       
  1195         // Check the bounding circle
       
  1196         if isCircleOffscreen(round(X), round(Y), (sqr(SpritesData[Sprite].Width) + sqr(SpritesData[Sprite].Height)) div 4) then
       
  1197             exit;
       
  1198     end
       
  1199     else
       
  1200     begin
       
  1201         if isDxAreaOffscreen(round(X) - SpritesData[Sprite].Width div 2, SpritesData[Sprite].Width) <> 0 then
       
  1202             exit;
       
  1203         if isDYAreaOffscreen(round(Y) - SpritesData[Sprite].Height div 2 , SpritesData[Sprite].Height) <> 0 then
       
  1204             exit;
       
  1205     end;
       
  1206 
       
  1207 
       
  1208     openglPushMatrix;
       
  1209     openglTranslatef(X, Y, 0);
       
  1210 
       
  1211 // mirror
       
  1212     if Dir < 0 then
       
  1213         openglScalef(-1.0, 1.0, 1.0);
       
  1214 
       
  1215 // apply angle after (conditional) mirroring
       
  1216     if Angle <> 0  then
       
  1217         openglRotatef(Angle, 0, 0, 1);
       
  1218 
       
  1219     UpdateModelviewProjection;
       
  1220 
       
  1221     DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
       
  1222 
       
  1223     openglPopMatrix;
       
  1224 
       
  1225     UpdateModelviewProjection;
  1186 
  1226 
  1187 end;
  1227 end;
  1188 
  1228 
  1189 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
  1229 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
  1190 begin
  1230 begin