hedgewars/uRender.pas
changeset 5441 39962b855540
parent 5235 e30b06ffea3a
child 5559 a937d43a032f
equal deleted inserted replaced
5439:25d3784dc0f6 5441:39962b855540
    20 
    20 
    21 unit uRender;
    21 unit uRender;
    22 
    22 
    23 interface
    23 interface
    24 
    24 
    25 uses SDLh, uTypes, GLunit;
    25 uses SDLh, uTypes, GLunit, uConsts;
    26 
    26 
    27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
    27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
    28 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
    28 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
    29 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
    29 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
    30 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
    30 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
   451     glPopMatrix
   451     glPopMatrix
   452 end;
   452 end;
   453 
   453 
   454 
   454 
   455 procedure Tint(r, g, b, a: Byte); inline;
   455 procedure Tint(r, g, b, a: Byte); inline;
   456 var nc: Longword;
   456 var nc, tw: Longword;
   457 begin
   457 begin
   458 nc:= (a shl 24) or (b shl 16) or (g shl 8) or r;
   458 nc:= (a shl 24) or (b shl 16) or (g shl 8) or r;
   459 if nc = lastTint then
   459 if nc = lastTint then
   460     exit;
   460     exit;
       
   461 if cGrayScale then
       
   462     begin
       
   463     tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE);
       
   464     if tw > 255 then tw:= 255;
       
   465     r:= tw;
       
   466     g:= tw;
       
   467     b:= tw
       
   468     end;
       
   469 
   461 glColor4ub(r, g, b, a);
   470 glColor4ub(r, g, b, a);
   462 lastTint:= nc;
   471 lastTint:= nc;
   463 end;
   472 end;
   464 
   473 
   465 procedure Tint(c: Longword); inline;
   474 procedure Tint(c: Longword); inline;