708 exit; |
708 exit; |
709 if isDyAreaOffscreen(Y, H) <> 0 then |
709 if isDyAreaOffscreen(Y, H) <> 0 then |
710 exit;} |
710 exit;} |
711 |
711 |
712 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
712 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
713 {if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then |
713 if (abs(X) > W) and ((abs(X + W / 2) - W / 2) * 2 > ViewWidth) then |
714 exit; |
714 exit; |
715 if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then |
715 if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) * 2 > ViewHeight) then |
716 exit;} |
716 exit; |
717 |
717 |
718 rr.x:= X; |
718 rr.x:= X; |
719 rr.y:= Y; |
719 rr.y:= Y; |
720 rr.w:= W; |
720 rr.w:= W; |
721 rr.h:= H; |
721 rr.h:= H; |
828 var ft, fb, fl, fr: GLfloat; |
828 var ft, fb, fl, fr: GLfloat; |
829 hw, hh, nx, ny: LongInt; |
829 hw, hh, nx, ny: LongInt; |
830 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
830 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
831 begin |
831 begin |
832 |
832 |
833 if isDxAreaOffscreen(X, w) <> 0 then |
833 // note: not taking scale into account |
|
834 if isAreaOffscreen(X, Y, w, h) then |
834 exit; |
835 exit; |
835 if isDyAreaOffscreen(Y, h) <> 0 then |
836 |
|
837 { |
|
838 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
|
839 if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * 2 > ViewWidth) then |
836 exit; |
840 exit; |
837 |
841 if (abs(Y) > H) and ((abs(Y + OffsetY - (cScreenHeight / 2)) - W / 2) * 2 > ViewHeight) then |
838 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
|
839 {if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then |
|
840 exit; |
842 exit; |
841 if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then |
843 } |
842 exit;} |
|
843 |
844 |
844 openglPushMatrix; |
845 openglPushMatrix; |
845 |
846 |
846 openglTranslatef(X, Y, 0); |
847 openglTranslatef(X, Y, 0); |
847 |
848 |
865 hw:= -w div 2; |
866 hw:= -w div 2; |
866 |
867 |
867 hh:= h div 2; |
868 hh:= h div 2; |
868 |
869 |
869 nx:= Texture^.w div w; // number of horizontal frames |
870 nx:= Texture^.w div w; // number of horizontal frames |
|
871 if nx = 0 then nx:= 1; // one frame is minimum |
870 ny:= Texture^.h div h; // number of vertical frames |
872 ny:= Texture^.h div h; // number of vertical frames |
|
873 if ny = 0 then ny:= 1; |
871 |
874 |
872 ft:= (Frame mod ny) * Texture^.ry / ny; |
875 ft:= (Frame mod ny) * Texture^.ry / ny; |
873 fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
876 fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
874 fl:= (Frame div ny) * Texture^.rx / nx; |
877 fl:= (Frame div ny) * Texture^.rx / nx; |
875 fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
878 fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
1084 |
1087 |
1085 procedure DrawRect(rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
1088 procedure DrawRect(rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
1086 var VertexBuffer: array [0..3] of TVertex2f; |
1089 var VertexBuffer: array [0..3] of TVertex2f; |
1087 begin |
1090 begin |
1088 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
1091 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
1089 {if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then |
1092 if (abs(rect.x) > rect.w) and ((abs(rect.x + rect.w / 2) - rect.w / 2) * 2 > ViewWidth) then |
1090 exit; |
1093 exit; |
1091 if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then |
1094 if (abs(rect.y) > rect.h) and ((abs(rect.y + rect.h / 2 - (cScreenHeight / 2)) - rect.h / 2) * 2 > ViewHeight) then |
1092 exit;} |
1095 exit; |
1093 |
1096 |
1094 EnableTexture(False); |
1097 EnableTexture(False); |
1095 |
1098 |
1096 Tint(r, g, b, a); |
1099 Tint(r, g, b, a); |
1097 |
1100 |
1156 (X: -16; Y: 16)); |
1159 (X: -16; Y: 16)); |
1157 var l, r, t, b: real; |
1160 var l, r, t, b: real; |
1158 TextureBuffer: array [0..3] of TVertex2f; |
1161 TextureBuffer: array [0..3] of TVertex2f; |
1159 begin |
1162 begin |
1160 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
1163 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
1161 if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then |
1164 if (abs(X) > 32) and ((abs(X) - 16) * 2 > ViewWidth) then |
1162 exit; |
1165 exit; |
1163 if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then |
1166 if (abs(Y) > 32) and ((abs(Y - cScreenHeight / 2) - 16) * 2 > ViewHeight) then |
1164 exit; |
1167 exit; |
1165 |
1168 |
1166 t:= Pos * 32 / HHTexture^.h; |
1169 t:= Pos * 32 / HHTexture^.h; |
1167 b:= (Pos + 1) * 32 / HHTexture^.h; |
1170 b:= (Pos + 1) * 32 / HHTexture^.h; |
1168 |
1171 |