hedgewars/uRender.pas
changeset 6688 b2084a00a4cf
parent 6580 6155187bf599
child 6689 98a239848ba2
equal deleted inserted replaced
6687:98be933770e0 6688:b2084a00a4cf
    40 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
    40 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
    41 procedure DrawFillRect(r: TSDL_Rect);
    41 procedure DrawFillRect(r: TSDL_Rect);
    42 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
    42 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
    43 procedure DrawCircle(X, Y, Radius, Width: LongInt);
    43 procedure DrawCircle(X, Y, Radius, Width: LongInt);
    44 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    44 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
       
    45 procedure DrawScreenWidget(widget: POnScreenWidget);
    45 procedure Tint(r, g, b, a: Byte); inline;
    46 procedure Tint(r, g, b, a: Byte); inline;
    46 procedure Tint(c: Longword); inline;
    47 procedure Tint(c: Longword); inline;
    47 
    48 
    48 
    49 
    49 implementation
    50 implementation
   445     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   446     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   446 
   447 
   447     glPopMatrix
   448     glPopMatrix
   448 end;
   449 end;
   449 
   450 
       
   451 procedure DrawScreenWidget(widget: POnScreenWidget);
       
   452 var alpha: byte = $FF;
       
   453 begin
       
   454 with widget^ do
       
   455     begin
       
   456     if (fadeAnimStart <> 0) then
       
   457         begin
       
   458         if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
       
   459             fadeAnimStart:= 0
       
   460         else
       
   461             if show then 
       
   462                 alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
       
   463             else 
       
   464                 alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
       
   465         end;
       
   466 
       
   467     with moveAnim do
       
   468         if animate then
       
   469             if RealTicks > (startTime + MOVE_ANIM_TIME) then
       
   470                 begin
       
   471                 startTime:= 0;
       
   472                 x:= targetToX;
       
   473                 y:= targetToY;
       
   474                 end
       
   475             else
       
   476                 begin
       
   477                 x:= targetFromX + Round((targetToX - targetFromX) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
       
   478                 y:= targetFromY + Round((targetToY - targetFromY) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
       
   479                 end;
       
   480 
       
   481     if show or (fadeAnimStart <> 0) then
       
   482         begin
       
   483         Tint($FF, $FF, $FF, alpha);
       
   484         DrawTexture(x, y, spritesData[sprite].Texture, buttonScale);
       
   485         Tint($FF, $FF, $FF, $FF);
       
   486         end;
       
   487     end;
       
   488 end;
   450 
   489 
   451 procedure Tint(r, g, b, a: Byte); inline;
   490 procedure Tint(r, g, b, a: Byte); inline;
   452 const 
   491 const 
   453     lastTint: Longword = 0;
   492     lastTint: Longword = 0;
   454 var 
   493 var