1 (* |
1 (* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
601 |
601 |
602 s:= filename + '.png'; |
602 s:= filename + '.png'; |
603 tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true); |
603 tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true); |
604 |
604 |
605 if tmpsurf = nil then |
605 if tmpsurf = nil then |
606 begin |
606 begin |
607 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
607 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
608 exit; |
608 exit; |
609 end; |
609 end; |
610 |
610 |
611 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
611 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
612 begin |
612 begin |
613 SDL_FreeSurface(tmpsurf); |
613 SDL_FreeSurface(tmpsurf); |
614 OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); |
614 OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); |
615 // dummy surface to replace non-critical textures that failed to load due to their size |
615 // dummy surface to replace non-critical textures that failed to load due to their size |
616 LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); |
616 LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); |
617 exit; |
617 exit; |
618 end; |
618 end; |
619 |
619 |
620 tmpsurf:= doSurfaceConversion(tmpsurf); |
620 tmpsurf:= doSurfaceConversion(tmpsurf); |
621 |
621 |
622 if (imageFlags and ifTransparent) <> 0 then |
622 if (imageFlags and ifTransparent) <> 0 then |
623 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
623 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |