hedgewars/uTextures.pas
changeset 5441 39962b855540
parent 4976 088d40d8aba2
child 6303 3edb3c857995
equal deleted inserted replaced
5439:25d3784dc0f6 5441:39962b855540
   129 glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id);
   129 glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id);
   130 
   130 
   131 if SDL_MustLock(surf) then
   131 if SDL_MustLock(surf) then
   132     SDLTry(SDL_LockSurface(surf) >= 0, true);
   132     SDLTry(SDL_LockSurface(surf) >= 0, true);
   133 
   133 
       
   134 fromP4:= Surf^.pixels;
       
   135 
       
   136 if cGrayScale then
       
   137     for y:= 0 to Pred(Surf^.h) do
       
   138         begin
       
   139         for x:= 0 to Pred(Surf^.w) do 
       
   140             begin
       
   141             tw:= fromP4^[x];
       
   142             tw:= round((tw shr RShift and $FF) * RGB_LUMINANCE_RED +  
       
   143                   (tw shr GShift and $FF) * RGB_LUMINANCE_GREEN + 
       
   144                   (tw shr BShift and $FF) * RGB_LUMINANCE_BLUE);
       
   145             if tw > 255 then tw:= 255;
       
   146             tw:= (tw and $FF shl RShift) or (tw and $FF shl BShift) or (tw and $FF shl GShift) or (fromP4^[x] and AMask);
       
   147             fromP4^[x]:= tw;
       
   148             end;
       
   149         fromP4:= @(fromP4^[Surf^.pitch div 4])
       
   150         end;
       
   151         
   134 if (not SupportNPOTT) and (not (isPowerOf2(Surf^.w) and isPowerOf2(Surf^.h))) then
   152 if (not SupportNPOTT) and (not (isPowerOf2(Surf^.w) and isPowerOf2(Surf^.h))) then
   135     begin
   153     begin
   136     tw:= toPowerOf2(Surf^.w);
   154     tw:= toPowerOf2(Surf^.w);
   137     th:= toPowerOf2(Surf^.h);
   155     th:= toPowerOf2(Surf^.h);
   138 
   156