hedgewars/uRender.pas
branchwebgl
changeset 8330 aaefa587e277
parent 8026 4a4f21070479
parent 8145 6408c0ba4ba1
child 8833 c13ebed437cb
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    53 procedure Tint                  (c: Longword); inline;
    53 procedure Tint                  (c: Longword); inline;
    54 
    54 
    55 implementation
    55 implementation
    56 uses uVariables;
    56 uses uVariables;
    57 
    57 
       
    58 {$IFDEF USE_TOUCH_INTERFACE}
       
    59 const
       
    60     FADE_ANIM_TIME = 500;
       
    61     MOVE_ANIM_TIME = 500;
       
    62 {$ENDIF}
       
    63 
    58 var LastTint: LongWord = 0;
    64 var LastTint: LongWord = 0;
    59 
    65 
    60 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
    66 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
    61 begin
    67 begin
    62 r.y:= r.y + Height * Position;
    68 r.y:= r.y + Height * Position;
   118 glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1);
   124 glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1);
   119 end;
   125 end;
   120 }
   126 }
   121 
   127 
   122 procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
   128 procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
   123 var 
   129 var
   124     rr: TSDL_Rect;
   130     rr: TSDL_Rect;
   125     VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   131     VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   126     //VertexBuffer, TextureBuffer: TVertexRect;
   132     //VertexBuffer, TextureBuffer: TVertexRect;
   127     _l, _r, _t, _b: GLfloat;
   133     _l, _r, _t, _b: GLfloat;
   128 begin
   134 begin
   477     VertexBuffer[1].Y:= Y1;
   483     VertexBuffer[1].Y:= Y1;
   478 
   484 
   479     SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
   485     SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
   480     glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   486     glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   481     Tint($FF, $FF, $FF, $FF);
   487     Tint($FF, $FF, $FF, $FF);
   482     
   488 
   483     glPopMatrix;
   489     glPopMatrix;
   484     
   490 
   485     glEnable(GL_TEXTURE_2D);
   491     glEnable(GL_TEXTURE_2D);
   486 
   492 
   487 {$ELSE}
   493 {$ELSE}
   488     EnableTexture(False);
   494     EnableTexture(False);
   489 
   495 
   548 glEnable(GL_TEXTURE_2D)
   554 glEnable(GL_TEXTURE_2D)
   549 {$ENDIF}
   555 {$ENDIF}
   550 
   556 
   551 end;
   557 end;
   552 
   558 
   553 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); 
   559 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
   554 begin
   560 begin
   555     Tint(r, g, b, a);
   561     Tint(r, g, b, a);
   556     DrawCircle(X, Y, Radius, Width); 
   562     DrawCircle(X, Y, Radius, Width);
   557     Tint($FF, $FF, $FF, $FF);
   563     Tint($FF, $FF, $FF, $FF);
   558 end;
   564 end;
   559 
   565 
   560 procedure DrawCircle(X, Y, Radius, Width: LongInt); 
   566 procedure DrawCircle(X, Y, Radius, Width: LongInt);
   561 var
   567 var
   562     i: LongInt;
   568     i: LongInt;
   563     CircleVertex: array [0..59] of TVertex2f;
   569     CircleVertex: array [0..59] of TVertex2f;
   564 begin
   570 begin
   565     for i := 0 to 59 do begin
   571     for i := 0 to 59 do begin
   668     if (fadeAnimStart <> 0) then
   674     if (fadeAnimStart <> 0) then
   669         begin
   675         begin
   670         if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
   676         if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
   671             fadeAnimStart:= 0
   677             fadeAnimStart:= 0
   672         else
   678         else
   673             if show then 
   679             if show then
   674                 alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
   680                 alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
   675             else 
   681             else
   676                 alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
   682                 alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
   677         end;
   683         end;
   678 
   684 
   679     with moveAnim do
   685     with moveAnim do
   680         if animate then
   686         if animate then