hedgewars/uRender.pas
author Wolfgang Steffens <WolfgangSteff@gmail.com>
Tue, 10 Jul 2012 16:38:50 +0200
changeset 7377 1aceade403ba
parent 7304 8b3575750cd2
child 11317 62287d4044e7
permissions -rw-r--r--
Debug commit Added code to replace sprites with a checkerboard pattern in order to identify filtering issues. This version only renders DrawSprite()'s with the checkerboard pattern for debugging purposes cleaned up some unneeded stuff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     1
(*
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6700
e04da46ee43c the most important commit of the year
koda
parents: 6695
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     4
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     8
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    12
 * GNU General Public License for more details.
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    13
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    14
 * You should have received a copy of the GNU General Public License
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    15
 * along with this program; if not, write to the Free Software
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    17
 *)
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    18
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    19
{$INCLUDE "options.inc"}
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    20
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    21
unit uRender;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    22
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    23
interface
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    24
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    25
uses SDLh, uTypes, GLunit, uConsts, uTextures, math;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    26
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    27
procedure DrawSprite            (Sprite: TSprite; X, Y, Frame: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    28
procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    29
procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    30
procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    31
procedure DrawSpriteRotatedF    (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    32
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    33
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    34
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    35
procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    36
procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    37
procedure DrawTextureCentered   (X, Top: LongInt; Source: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    38
procedure DrawTextureF          (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    39
procedure DrawTextureRotated    (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    40
procedure DrawTextureRotatedF   (Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    41
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    42
procedure DrawCircle            (X, Y, Radius, Width: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    43
procedure DrawCircle            (X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    44
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    45
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    46
procedure DrawFillRect          (r: TSDL_Rect);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    47
procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    48
procedure DrawScreenWidget      (widget: POnScreenWidget);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    49
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    50
// This is just temporary and becomes non public once everything changed to GL2
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    51
procedure UpdateModelview;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    52
procedure ResetModelview;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    53
procedure SetOffset(X, Y: Longint);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    54
procedure ResetRotation;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    55
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
    56
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    57
implementation
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    58
uses uVariables, uStore;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    59
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    60
const DegToRad =  0.01745329252; // 2PI / 360
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    61
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    62
procedure UpdateModelview;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    63
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    64
{$IFDEF GL2}
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    65
    UpdateModelviewProjection;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    66
{$ELSE}
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    67
    glLoadMatrixf(@mModelview[0,0]);
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    68
{$ENDIF}
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    69
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    70
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    71
procedure ResetModelview;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    72
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    73
    mModelview[0,0]:= 1.0; mModelview[1,0]:=0.0; mModelview[3,0]:= 0;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    74
    mModelview[0,1]:= 0.0; mModelview[1,1]:=1.0; mModelview[3,1]:= 0;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    75
    UpdateModelview;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    76
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    77
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    78
procedure SetOffset(X, Y: Longint);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    79
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    80
    mModelview[3,0]:= X;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    81
    mModelview[3,1]:= Y;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    82
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    83
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    84
procedure AddOffset(X, Y: GLfloat); // probably want to refactor this to use integers
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    85
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    86
    mModelview[3,0]:=mModelview[3,0] + mModelview[0,0]*X + mModelview[1,0]*Y;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    87
    mModelview[3,1]:=mModelview[3,1] + mModelview[0,1]*X + mModelview[1,1]*Y;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    88
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    89
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    90
procedure SetScale(Scale: GLfloat);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    91
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    92
    mModelview[0,0]:= Scale;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    93
    mModelview[1,1]:= Scale;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    94
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    95
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    96
procedure AddScale(Scale: GLfloat);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
    97
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    98
    mModelview[0,0]:= mModelview[0,0]*Scale; mModelview[1,0]:= mModelview[1,0]*Scale;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
    99
    mModelview[0,1]:= mModelview[0,1]*Scale; mModelview[1,1]:= mModelview[1,1]*Scale;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   100
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   101
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   102
procedure AddScale(X, Y: GLfloat);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   103
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   104
    mModelview[0,0]:= mModelview[0,0]*X; mModelview[1,0]:= mModelview[1,0]*Y;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   105
    mModelview[0,1]:= mModelview[0,1]*X; mModelview[1,1]:= mModelview[1,1]*Y;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   106
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   107
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   108
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   109
procedure SetRotation(Angle, ZAxis: GLfloat);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   110
var s, c: Extended;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   111
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   112
    SinCos(Angle*DegToRad, s, c);
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   113
    mModelview[0,0]:= c;       mModelview[1,0]:=-s*ZAxis;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   114
    mModelview[0,1]:= s*ZAxis; mModelview[1,1]:= c;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   115
end;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   116
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   117
procedure ResetRotation;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   118
begin
7138
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   119
    mModelview[0,0]:= 1.0; mModelview[1,0]:=0.0;
f8248bcba8f1 moved generic matrix code to uMatrix.pas
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7111
diff changeset
   120
    mModelview[0,1]:= 0.0; mModelview[1,1]:=1.0;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   121
end;
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
   122
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   123
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   124
begin
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   125
    r.y:= r.y + Height * Position;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   126
    r.h:= Height;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   127
    DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   128
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   129
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   130
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   131
begin
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   132
    DrawTextureFromRect(X, Y, r^.w, r^.h, r, SourceTexture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   133
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   134
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   135
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   136
var 
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   137
    rr: TSDL_Rect;
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   138
    VertexBuffer, TextureBuffer: TVertexRect;
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   139
    _l, _r, _t, _b: GLfloat;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   140
begin
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   141
    if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   142
        exit;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   143
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   144
    // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   145
    if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   146
        exit;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   147
    if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   148
        exit;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   149
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   150
    rr.x:= X;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   151
    rr.y:= Y;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   152
    rr.w:= W;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   153
    rr.h:= H;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   154
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   155
    glBindTexture(GL_TEXTURE_2D, SourceTexture^.atlas^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   156
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   157
    ComputeTexcoords(SourceTexture, r, @TextureBuffer);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   158
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   159
    _l:= X + SourceTexture^.cropInfo.l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   160
    _r:= X + rr.w - SourceTexture^.cropInfo.l - SourceTexture^.cropInfo.r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   161
    _t:= Y + SourceTexture^.cropInfo.t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   162
    _b:= Y + rr.h - SourceTexture^.cropInfo.t - SourceTexture^.cropInfo.b;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   163
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   164
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   165
    VertexBuffer[0].X:= _l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   166
    VertexBuffer[0].Y:= _t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   167
    VertexBuffer[1].X:= _r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   168
    VertexBuffer[1].Y:= _t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   169
    VertexBuffer[2].X:= _r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   170
    VertexBuffer[2].Y:= _b;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   171
    VertexBuffer[3].X:= _l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   172
    VertexBuffer[3].Y:= _b;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   173
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   174
    SetVertexPointer(@VertexBuffer[0]);
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   175
    //SetTexCoordPointer(@TextureBuffer[0]);
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   176
    SetTexCoordPointer(@SourceTexture^.tb[0]);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   177
    //glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   178
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   179
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   180
procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   181
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   182
    DrawTexture(X, Y, Texture, 1.0);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   183
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   184
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   185
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   186
begin
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   187
    SetOffset(X, Y);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   188
    ResetRotation;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   189
    SetScale(Scale);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   190
    UpdateModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   191
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   192
    glBindTexture(GL_TEXTURE_2D, Texture^.atlas^.id);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   193
    SetVertexPointer(@Texture^.vb);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   194
    SetTexCoordPointer(@Texture^.tb);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   195
    //glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   196
    glBindTexture(GL_TEXTURE_2D, 0); // DEBUG
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   197
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   198
    ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   199
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   200
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   201
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   202
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   203
    DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   204
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   205
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   206
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real);
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   207
var hw, nx, ny: LongInt;
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   208
    r: TSDL_Rect;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   209
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   210
    _l, _r, _t, _b: GLfloat;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   211
begin
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   212
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   213
    while (Frame > 0) and (Texture <> nil) do
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   214
    begin
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   215
        Texture:= Texture^.nextFrame;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   216
        dec(Frame);
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   217
    end;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   218
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   219
    if Texture = nil then
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   220
        exit;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   221
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   222
    // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   223
    if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   224
        exit;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   225
    if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   226
        exit;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   227
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   228
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   229
    SetOffset(X, Y);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   230
    if Dir = 0 then
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   231
        Dir:= 1;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   232
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   233
    SetRotation(Angle, Dir);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   234
    AddOffset(Dir*OffsetX, OffsetY);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   235
    AddScale(Scale);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   236
    UpdateModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   237
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   238
// Any reason for this call? And why only in t direction, not s?
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   239
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   240
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   241
    hw:= w div (2 div Dir);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   242
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   243
    r.y:=0;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   244
    r.x:=0;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   245
    r.w:=w;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   246
    r.h:=h;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   247
    ComputeTexcoords(Texture, @r, @TextureBuffer);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   248
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   249
    glBindTexture(GL_TEXTURE_2D, Texture^.atlas^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   250
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   251
    _l:= -hw + Texture^.cropInfo.l;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   252
    _t:= w/-2 + Texture^.cropInfo.t;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   253
    _r:= hw - Texture^.cropInfo.l - Texture^.cropInfo.r;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   254
    _b:= w/2 - Texture^.cropInfo.t - Texture^.cropInfo.b;
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   255
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   256
    VertexBuffer[0].X:= _l;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   257
    VertexBuffer[0].Y:= _t;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   258
    VertexBuffer[1].X:= _r;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   259
    VertexBuffer[1].Y:= _t;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   260
    VertexBuffer[2].X:= _r;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   261
    VertexBuffer[2].Y:= _b;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   262
    VertexBuffer[3].X:= _l;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   263
    VertexBuffer[3].Y:= _b;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   264
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   265
    //SetVertexPointer(@VertexBuffer[0]);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   266
    //SetTexCoordPointer(@TextureBuffer[0]);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   267
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   268
    SetVertexPointer(@Texture^.vb[0]);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   269
    SetTexCoordPointer(@Texture^.tb[0]);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   270
    //glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   271
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   272
    ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   273
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   274
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   275
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   276
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   277
    DrawTextureRotated(SpritesData[Sprite].Texture,
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   278
        SpritesData[Sprite].Width,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   279
        SpritesData[Sprite].Height,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   280
        X, Y, Dir, Angle)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   281
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   282
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   283
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   284
var VertexBuffer: array [0..3] of TVertex2f;
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   285
    _l, _r, _t, _b: GLfloat;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   286
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   287
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   288
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   289
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   290
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   291
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   292
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   293
SetOffset(X, Y);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   294
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   295
if Dir < 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   296
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   297
    hw:= - hw;
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   298
    SetRotation(Angle, -1.0);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   299
    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   300
else
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   301
    SetRotation(Angle, 1.0);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   302
UpdateModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   303
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   304
glBindTexture(GL_TEXTURE_2D, Texture^.atlas^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   305
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   306
_l:= -hw + Texture^.cropInfo.l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   307
_t:= -hh + Texture^.cropInfo.t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   308
_r:= hw - Texture^.cropInfo.l - Texture^.cropInfo.r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   309
_b:= hh - Texture^.cropInfo.t - Texture^.cropInfo.b;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   310
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   311
VertexBuffer[0].X:= _l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   312
VertexBuffer[0].Y:= _t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   313
VertexBuffer[1].X:= _r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   314
VertexBuffer[1].Y:= _t;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   315
VertexBuffer[2].X:= _r;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   316
VertexBuffer[2].Y:= _b;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   317
VertexBuffer[3].X:= _l;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   318
VertexBuffer[3].Y:= _b;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   319
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   320
SetVertexPointer(@VertexBuffer[0]);
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   321
SetTexCoordPointer(@Texture^.tb);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   322
//glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   323
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   324
ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   325
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   326
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   327
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   328
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   329
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   330
var
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   331
    tex: PTexture;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   332
begin
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   333
    if SpritesData[Sprite].imageHeight = 0 then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   334
        exit;
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   335
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   336
    tex:= SpritesData[Sprite].Texture;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   337
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   338
    while (Frame > 0) and (tex <> nil) do
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   339
    begin
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   340
        tex:= tex^.nextFrame;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   341
        dec(Frame);
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   342
    end;
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   343
7304
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   344
    if (tex = nil) or (tex^.w = 0) or (tex^.h = 0) then
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   345
        exit;
8b3575750cd2 Added auto cropping to atlasing
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7188
diff changeset
   346
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   347
    SetOffset(X, Y);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   348
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   349
    if Dir < 0 then
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   350
    begin
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   351
        SetRotation(Angle, -1.0);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   352
        AddScale(-1.0, 1.0);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   353
    end 
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   354
    else
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   355
        SetRotation(Angle, 1.0);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   356
        
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   357
    UpdateModelview;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   358
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   359
    glBindTexture(GL_TEXTURE_2D, tex^.atlas^.id);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   360
    SetVertexPointer(@tex^.vb);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   361
    SetTexCoordPointer(@tex^.tb);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   362
    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(tex^.vb));
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   363
    glBindTexture(GL_TEXTURE_2D, 0); // DEBUG
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   364
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   365
    ResetModelview;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   366
end;
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   367
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   368
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   369
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   370
begin
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   371
    DrawSpriteRotatedF(Sprite, X, Y, Frame, 1, 0.0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   372
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   373
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   374
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   375
var r: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   376
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   377
r.x:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   378
r.y:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   379
r.w:= SpritesData[Sprite].Width;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   380
r.h:= SpritesData[Sprite].Height;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   381
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   382
if (X < LeftX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   383
    r.x:= LeftX - X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   384
if (Y < TopY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   385
    r.y:= TopY - Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   386
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   387
if (Y + SpritesData[Sprite].Height > BottomY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   388
    r.h:= BottomY - Y + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   389
if (X + SpritesData[Sprite].Width > RightX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   390
    r.w:= RightX - X + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   391
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   392
dec(r.h, r.y);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   393
dec(r.w, r.x);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   394
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   395
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   396
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   397
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   398
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   399
var scale: GLfloat;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   400
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   401
    if (Source^.w + 20) > cScreenWidth then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   402
        scale:= cScreenWidth / (Source^.w + 20)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   403
    else
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   404
        scale:= 1.0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   405
    DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   406
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   407
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   408
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   409
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   410
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   411
    glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   412
    glEnable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   413
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   414
    ResetRotation;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   415
    SetOffset(WorldDx, WorldDy);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   416
    UpdateModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   417
    glLineWidth(Width);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   418
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   419
    Tint(r, g, b, a);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   420
    VertexBuffer[0].X:= X0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   421
    VertexBuffer[0].Y:= Y0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   422
    VertexBuffer[1].X:= X1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   423
    VertexBuffer[1].Y:= Y1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   424
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   425
    SetVertexPointer(@VertexBuffer[0]);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   426
    //glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   427
    Tint($FF, $FF, $FF, $FF);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   428
    
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   429
    ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   430
    
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   431
    glEnable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   432
    glDisable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   433
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   434
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   435
procedure DrawFillRect(r: TSDL_Rect);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   436
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   437
begin
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   438
SetOffset(0, 0);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   439
ResetRotation;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   440
UpdateModelview;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   441
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   442
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   443
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   444
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   445
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   446
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   447
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   448
glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   449
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   450
Tint($00, $00, $00, $80);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   451
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   452
VertexBuffer[0].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   453
VertexBuffer[0].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   454
VertexBuffer[1].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   455
VertexBuffer[1].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   456
VertexBuffer[2].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   457
VertexBuffer[2].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   458
VertexBuffer[3].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   459
VertexBuffer[3].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   460
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   461
SetVertexPointer(@VertexBuffer[0]);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   462
//glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   463
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   464
Tint($FF, $FF, $FF, $FF);
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   465
glEnable(GL_TEXTURE_2D);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   466
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   467
ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   468
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   469
4420
6be946bcd17a Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents: 4385
diff changeset
   470
procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); 
4451
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   471
begin
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   472
    Tint(r, g, b, a);
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   473
    DrawCircle(X, Y, Radius, Width); 
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   474
    Tint($FF, $FF, $FF, $FF);
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   475
end;
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   476
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
   477
procedure DrawCircle(X, Y, Radius, Width: LongInt); 
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   478
var
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   479
    i: LongInt;
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   480
    CircleVertex: array [0..59] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   481
begin
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   482
    for i := 0 to 59 do begin
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   483
        CircleVertex[i].X := X + Radius*cos(i*pi/30);
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   484
        CircleVertex[i].Y := Y + Radius*sin(i*pi/30);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   485
    end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   486
    glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   487
    glEnable(GL_LINE_SMOOTH);
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   488
    SetOffset(0, 0);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   489
    ResetRotation;
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   490
    UpdateModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   491
    glLineWidth(Width);
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   492
    SetVertexPointer(@CircleVertex[0]);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   493
    //glDrawArrays(GL_LINE_LOOP, 0, 60);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   494
    glEnable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   495
    glDisable(GL_LINE_SMOOTH);
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   496
    ResetModelview;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   497
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   498
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   499
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   500
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   501
const VertexBuffers: array[0..1] of TVertexRect = (
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   502
        ((x: -16; y: -16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   503
         (x:  16; y: -16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   504
         (x:  16; y:  16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   505
         (x: -16; y:  16)),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   506
        ((x:  16; y: -16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   507
         (x: -16; y: -16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   508
         (x: -16; y:  16),
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   509
         (x:  16; y:  16)));
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   510
var r: TSDL_Rect;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   511
    TextureBuffer: array [0..3] of TVertex2f;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   512
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   513
    // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   514
    if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   515
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   516
    if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   517
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   518
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   519
    r.x:=Step * 32;
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   520
    r.y:=Pos * 32;
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   521
    r.w:=32;
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   522
    r.h:=32;
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   523
    ComputeTexcoords(HHTexture, @r, @TextureBuffer);
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   524
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   525
    SetOffset(X, Y);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   526
    SetRotation(Angle, 1.0);
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   527
    UpdateModelview;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   528
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   529
    glBindTexture(GL_TEXTURE_2D, HHTexture^.atlas^.id);
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   530
    if Dir = -1 then
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   531
        SetVertexPointer(@VertexBuffers[1][0])
7080
dbf43c07a507 Refactored TTexture to allow encoding sprite(s) at an arbitrary location within
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7069
diff changeset
   532
    else
7188
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   533
        SetVertexPointer(@VertexBuffers[0][0]);
580cd247511e Removed leftover FFP code: We should now be GL2 GLSL1.30+ forward compatible.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7138
diff changeset
   534
    SetTexCoordPointer(@TextureBuffer[0]);
7377
1aceade403ba Debug commit
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7304
diff changeset
   535
    //glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   536
7111
5ba5a92d74fb Replaced matrix related FFP code with explicit matrix calculations.
Wolfgang Steffens <WolfgangSteff@gmail.com>
parents: 7080
diff changeset
   537
    ResetModelview;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   538
end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   539
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   540
procedure DrawScreenWidget(widget: POnScreenWidget);
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   541
{$IFDEF USE_TOUCH_INTERFACE}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   542
var alpha: byte = $FF;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   543
begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   544
with widget^ do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   545
    begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   546
    if (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   547
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   548
        if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   549
            fadeAnimStart:= 0
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   550
        else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   551
            if show then 
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   552
                alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   553
            else 
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   554
                alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   555
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   556
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   557
    with moveAnim do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   558
        if animate then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   559
            if RealTicks > (startTime + MOVE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   560
                begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   561
                startTime:= 0;
6710
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
   562
                animate:= false;
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   563
                frame.x:= target.x;
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   564
                frame.y:= target.y;
6710
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
   565
                active.x:= active.x + (target.x - source.x);
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
   566
                active.y:= active.y + (target.y - source.y);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   567
                end
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   568
            else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   569
                begin
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   570
                frame.x:= source.x + Round((target.x - source.x) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   571
                frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   572
                end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   573
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   574
    if show or (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   575
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   576
        Tint($FF, $FF, $FF, alpha);
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   577
        DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   578
        Tint($FF, $FF, $FF, $FF);
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   579
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   580
    end;
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   581
{$ELSE}
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   582
begin
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   583
widget:= widget; // avoid hint
6689
98a239848ba2 wops, added an extra USE_TOUCH_INTERFACE
Xeli
parents: 6688
diff changeset
   584
{$ENDIF}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   585
end;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   586
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   587
end.