hedgewars/uRender.pas
changeset 9666 8dcb25112d96
parent 9557 a5005b7ca305
child 9792 59cde1e53ca5
equal deleted inserted replaced
9665:bfd62e380327 9666:8dcb25112d96
    50 procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    50 procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    51 procedure DrawScreenWidget      (widget: POnScreenWidget);
    51 procedure DrawScreenWidget      (widget: POnScreenWidget);
    52 
    52 
    53 procedure Tint                  (r, g, b, a: Byte); inline;
    53 procedure Tint                  (r, g, b, a: Byte); inline;
    54 procedure Tint                  (c: Longword); inline;
    54 procedure Tint                  (c: Longword); inline;
       
    55 procedure untint(); inline;
       
    56 procedure setTintAdd            (f: boolean); inline;
    55 
    57 
    56 
    58 
    57 implementation
    59 implementation
    58 uses uVariables;
    60 uses uVariables;
    59 
    61 
   370     VertexBuffer[1].X:= X1;
   372     VertexBuffer[1].X:= X1;
   371     VertexBuffer[1].Y:= Y1;
   373     VertexBuffer[1].Y:= Y1;
   372 
   374 
   373     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   375     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   374     glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   376     glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   375     Tint($FF, $FF, $FF, $FF);
   377     untint;
   376     
   378     
   377     glPopMatrix;
   379     glPopMatrix;
   378     
   380     
   379     glEnable(GL_TEXTURE_2D);
   381     glEnable(GL_TEXTURE_2D);
   380     glDisable(GL_LINE_SMOOTH);
   382     glDisable(GL_LINE_SMOOTH);
   403 VertexBuffer[3].Y:= r.y + r.h;
   405 VertexBuffer[3].Y:= r.y + r.h;
   404 
   406 
   405 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   407 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   406 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   408 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   407 
   409 
   408 Tint($FF, $FF, $FF, $FF);
   410 untint;
   409 glEnable(GL_TEXTURE_2D)
   411 glEnable(GL_TEXTURE_2D)
   410 end;
   412 end;
   411 
   413 
   412 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); 
   414 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); 
   413 begin
   415 begin
   414     Tint(r, g, b, a);
   416     Tint(r, g, b, a);
   415     DrawCircle(X, Y, Radius, Width); 
   417     DrawCircle(X, Y, Radius, Width); 
   416     Tint($FF, $FF, $FF, $FF);
   418     untint;
   417 end;
   419 end;
   418 
   420 
   419 procedure DrawCircle(X, Y, Radius, Width: LongInt); 
   421 procedure DrawCircle(X, Y, Radius, Width: LongInt); 
   420 var
   422 var
   421     i: LongInt;
   423     i: LongInt;
   525 
   527 
   526     if show or (fadeAnimStart <> 0) then
   528     if show or (fadeAnimStart <> 0) then
   527         begin
   529         begin
   528         Tint($FF, $FF, $FF, alpha);
   530         Tint($FF, $FF, $FF, alpha);
   529         DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
   531         DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
   530         Tint($FF, $FF, $FF, $FF);
   532         untint;
   531         end;
   533         end;
   532     end;
   534     end;
   533 {$ELSE}
   535 {$ELSE}
   534 begin
   536 begin
   535 widget:= widget; // avoid hint
   537 widget:= widget; // avoid hint
   562 begin
   564 begin
   563     if c = lastTint then exit;
   565     if c = lastTint then exit;
   564     Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
   566     Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
   565 end;
   567 end;
   566 
   568 
       
   569 procedure untint(); inline;
       
   570 begin
       
   571     Tint($FF, $FF, $FF, $FF)
       
   572 end;
       
   573 
       
   574 procedure setTintAdd(f: boolean); inline;
       
   575 begin
       
   576     if f then
       
   577         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
       
   578     else
       
   579         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       
   580 end;
       
   581 
   567 end.
   582 end.