649 begin |
650 begin |
650 // output sdl error if loading failed when data source was available |
651 // output sdl error if loading failed when data source was available |
651 if rwops <> nil then |
652 if rwops <> nil then |
652 begin |
653 begin |
653 // anounce that loading failed |
654 // anounce that loading failed |
654 OutError(msgFailed, false); |
655 OutError(logMsg + ' ' + msgFailed, false); |
655 |
656 |
656 if SDLCheck(false, 'LoadImage', (imageFlags and ifCritical) <> 0) then exit; |
657 if SDLCheck(false, 'LoadImage: ' + logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0) then |
|
658 exit; |
657 // rwops was already freed by IMG_Load_RW |
659 // rwops was already freed by IMG_Load_RW |
658 rwops:= nil; |
660 rwops:= nil; |
659 end else |
661 end |
660 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
662 else |
|
663 OutError(logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0); |
661 exit; |
664 exit; |
662 end; |
665 end; |
663 |
666 |
664 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
667 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
665 begin |
668 begin |
666 SDL_FreeSurface(tmpsurf); |
669 SDL_FreeSurface(tmpsurf); |
667 OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); |
670 OutError(logMsg + ' ' + msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); |
668 // dummy surface to replace non-critical textures that failed to load due to their size |
671 // dummy surface to replace non-critical textures that failed to load due to their size |
669 LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); |
672 LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); |
670 exit; |
673 exit; |
671 end; |
674 end; |
672 |
675 |
673 tmpsurf:= doSurfaceConversion(tmpsurf); |
676 tmpsurf:= doSurfaceConversion(tmpsurf); |
674 |
677 |
675 if (imageFlags and ifColorKey) <> 0 then |
678 if (imageFlags and ifColorKey) <> 0 then |
676 if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit; |
679 if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit; |
677 |
680 |
678 WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
681 // log success |
|
682 WriteLnToConsole(logMsg + ' ' + msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
679 |
683 |
680 LoadImage:= tmpsurf //Result |
684 LoadImage:= tmpsurf //Result |
681 end; |
685 end; |
682 |
686 |
683 |
687 |