hedgewars/uTextures.pas
branchqmlfrontend
changeset 11544 b69f5f22a3ba
parent 11532 bf86c6cb9341
child 12765 d01e9dd5c439
equal deleted inserted replaced
11481:caa1e84c3ac2 11544:b69f5f22a3ba
   174 var
   174 var
   175     // current row index, second last row index of array, width and first/last i of row
   175     // current row index, second last row index of array, width and first/last i of row
   176     r, slr, w, si, li: LongWord;
   176     r, slr, w, si, li: LongWord;
   177 begin
   177 begin
   178     w:= surf^.w;
   178     w:= surf^.w;
       
   179     // just a single pixel, nothing to do here
       
   180     if (w < 2) and (surf^.h < 2) then
       
   181         exit;
   179     slr:= surf^.h - 2;
   182     slr:= surf^.h - 2;
   180     si:= 0;
   183     si:= 0;
   181     li:= w - 1;
   184     li:= w - 1;
   182     for r:= 0 to slr do
   185     for r:= 0 to slr do
   183         begin
   186         begin
   224 Surface2Tex^.w:= surf^.w;
   227 Surface2Tex^.w:= surf^.w;
   225 Surface2Tex^.h:= surf^.h;
   228 Surface2Tex^.h:= surf^.h;
   226 
   229 
   227 if (surf^.format^.BytesPerPixel <> 4) then
   230 if (surf^.format^.BytesPerPixel <> 4) then
   228     begin
   231     begin
   229     TryDo(false, 'Surface2Tex failed, expecting 32 bit surface', true);
   232     checkFails(false, 'Surface2Tex failed, expecting 32 bit surface', true);
   230     Surface2Tex^.id:= 0;
   233     Surface2Tex^.id:= 0;
   231     exit
   234     exit
   232     end;
   235     end;
   233 
   236 
   234 glGenTextures(1, @Surface2Tex^.id);
   237 glGenTextures(1, @Surface2Tex^.id);
   235 
   238 
   236 glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id);
   239 glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id);
   237 
   240 
   238 if SDL_MustLock(surf) then
   241 if SDL_MustLock(surf) then
   239     SDLTry(SDL_LockSurface(surf) >= 0, 'Lock surface', true);
   242     if SDLCheck(SDL_LockSurface(surf) >= 0, 'Lock surface', true) then
       
   243         exit(nil);
   240 
   244 
   241 fromP4:= Surf^.pixels;
   245 fromP4:= Surf^.pixels;
   242 
   246 
   243 if GrayScale then
   247 if GrayScale then
   244     Surface2GrayScale(Surf);
   248     Surface2GrayScale(Surf);