hedgewars/uRender.pas
author koda
Fri, 04 Jan 2013 02:58:19 +0100
changeset 8357 d7bef04c99d4
parent 8145 6408c0ba4ba1
child 8330 aaefa587e277
child 8560 134a098235fa
permissions -rw-r--r--
GCI2012: Resolution Freedom
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
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5235
diff changeset
    25
uses SDLh, uTypes, GLunit, uConsts;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
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 DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    29
procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    30
procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    31
procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    32
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
    33
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    34
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    35
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    36
procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    37
procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    38
procedure DrawTextureCentered   (X, Top: LongInt; Source: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    39
procedure DrawTextureF          (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    40
procedure DrawTextureRotated    (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    41
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
    42
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    43
procedure DrawCircle            (X, Y, Radius, Width: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    44
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
    45
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    46
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    47
procedure DrawFillRect          (r: TSDL_Rect);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    48
procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    49
procedure DrawScreenWidget      (widget: POnScreenWidget);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    50
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    51
procedure Tint                  (r, g, b, a: Byte); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    52
procedure Tint                  (c: Longword); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    53
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
    54
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    55
implementation
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    56
uses uVariables;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    57
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    58
{$IFDEF USE_TOUCH_INTERFACE}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    59
const
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    60
    FADE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    61
    MOVE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    62
{$ENDIF}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    63
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
    64
var LastTint: LongWord = 0;
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
    65
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    66
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    67
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    68
r.y:= r.y + Height * Position;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    69
r.h:= Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    70
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    71
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    72
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    73
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    74
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    75
DrawTextureFromRect(X, Y, r^.w, r^.h, r, SourceTexture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    76
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    77
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    78
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    79
var rr: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    80
    _l, _r, _t, _b: real;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    81
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    82
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
    83
if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
    84
    exit;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    85
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
    86
// 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
    87
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    88
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    89
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    90
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    91
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    92
rr.x:= X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    93
rr.y:= Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    94
rr.w:= W;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    95
rr.h:= H;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    96
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    97
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    98
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    99
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   100
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   101
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   102
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   103
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   104
VertexBuffer[0].X:= X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   105
VertexBuffer[0].Y:= Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   106
VertexBuffer[1].X:= rr.w + X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   107
VertexBuffer[1].Y:= Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   108
VertexBuffer[2].X:= rr.w + X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   109
VertexBuffer[2].Y:= rr.h + Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   110
VertexBuffer[3].X:= X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   111
VertexBuffer[3].Y:= rr.h + Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   112
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   113
TextureBuffer[0].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   114
TextureBuffer[0].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   115
TextureBuffer[1].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   116
TextureBuffer[1].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   117
TextureBuffer[2].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   118
TextureBuffer[2].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   119
TextureBuffer[3].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   120
TextureBuffer[3].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   121
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   122
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   123
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   124
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   125
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   126
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   127
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
   128
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   129
    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
   130
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   131
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   132
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   133
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   134
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   135
glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   136
glTranslatef(X, Y, 0);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   137
glScalef(Scale, Scale, 1);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   138
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   139
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   140
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   141
glVertexPointer(2, GL_FLOAT, 0, @Texture^.vb);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   142
glTexCoordPointer(2, GL_FLOAT, 0, @Texture^.tb);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   143
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   144
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   145
glPopMatrix
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   146
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   147
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   148
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   149
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   150
    DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   151
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   152
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   153
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   154
var ft, fb, fl, fr: GLfloat;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   155
    hw, nx, ny: LongInt;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   156
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   157
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   158
// 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
   159
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   160
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   161
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   162
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   163
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   164
glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   165
glTranslatef(X, Y, 0);
6323
c1aa6a3c84a7 Dir should not be 0, but set it to 1 if 0 in case I missed some other place this was done. Also correct cloud scaling.
nemo
parents: 6322
diff changeset
   166
if Dir = 0 then Dir:= 1;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   167
6323
c1aa6a3c84a7 Dir should not be 0, but set it to 1 if 0 in case I missed some other place this was done. Also correct cloud scaling.
nemo
parents: 6322
diff changeset
   168
glRotatef(Angle, 0, 0, Dir);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   169
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   170
glTranslatef(Dir*OffsetX, OffsetY, 0);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   171
glScalef(Scale, Scale, 1);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   172
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   173
// Any reason for this call? And why only in t direction, not s?
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   174
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   175
6322
b310f0bc8dde If I'm going to be arbitrary about it, might as well go for the more minimal arbitrariness
nemo
parents: 6318
diff changeset
   176
hw:= w div (2 div Dir);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   177
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   178
nx:= round(Texture^.w / w); // number of horizontal frames
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   179
ny:= round(Texture^.h / h); // number of vertical frames
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   180
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   181
ft:= (Frame mod ny) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   182
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   183
fl:= (Frame div ny) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   184
fr:= ((Frame div ny) + 1) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   185
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   186
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   187
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   188
VertexBuffer[0].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   189
VertexBuffer[0].Y:= w / -2;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   190
VertexBuffer[1].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   191
VertexBuffer[1].Y:= w / -2;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   192
VertexBuffer[2].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   193
VertexBuffer[2].Y:= w / 2;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   194
VertexBuffer[3].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   195
VertexBuffer[3].Y:= w / 2;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   196
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   197
TextureBuffer[0].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   198
TextureBuffer[0].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   199
TextureBuffer[1].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   200
TextureBuffer[1].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   201
TextureBuffer[2].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   202
TextureBuffer[2].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   203
TextureBuffer[3].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   204
TextureBuffer[3].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   205
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   206
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   207
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   208
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   209
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   210
glPopMatrix
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   211
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   212
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   213
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   214
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   215
    DrawTextureRotated(SpritesData[Sprite].Texture,
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   216
        SpritesData[Sprite].Width,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   217
        SpritesData[Sprite].Height,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   218
        X, Y, Dir, Angle)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   219
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   220
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   221
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   222
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   223
glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   224
glTranslatef(X, Y, 0);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   225
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   226
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
   227
    glRotatef(Angle, 0, 0, -1)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   228
else
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   229
    glRotatef(Angle, 0, 0,  1);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   230
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   231
    glScalef(-1.0, 1.0, 1.0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   232
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   233
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   234
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   235
glPopMatrix
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   236
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   237
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   238
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   239
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   240
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   241
// 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
   242
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   243
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   244
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   245
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   246
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   247
glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   248
glTranslatef(X, Y, 0);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   249
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   250
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
   251
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   252
    hw:= - hw;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   253
    glRotatef(Angle, 0, 0, -1);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   254
    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   255
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   256
    glRotatef(Angle, 0, 0,  1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   257
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   258
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   259
glBindTexture(GL_TEXTURE_2D, Texture^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   260
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   261
VertexBuffer[0].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   262
VertexBuffer[0].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   263
VertexBuffer[1].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   264
VertexBuffer[1].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   265
VertexBuffer[2].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   266
VertexBuffer[2].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   267
VertexBuffer[3].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   268
VertexBuffer[3].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   269
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   270
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   271
glTexCoordPointer(2, GL_FLOAT, 0, @Texture^.tb);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   272
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   273
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   274
glPopMatrix
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   275
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   276
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   277
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   278
var row, col, numFramesFirstCol: LongInt;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   279
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
   280
    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
   281
        exit;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   282
    numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   283
    row:= Frame mod numFramesFirstCol;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   284
    col:= Frame div numFramesFirstCol;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   285
    DrawSprite(Sprite, X, Y, col, row);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   286
end;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   287
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   288
procedure DrawSprite(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   289
var r: TSDL_Rect;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   290
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   291
    r.x:= FrameX * SpritesData[Sprite].Width;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   292
    r.w:= SpritesData[Sprite].Width;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   293
    r.y:= FrameY * SpritesData[Sprite].Height;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   294
    r.h:= SpritesData[Sprite].Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   295
    DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   296
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   297
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   298
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   299
var r: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   300
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   301
r.x:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   302
r.y:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   303
r.w:= SpritesData[Sprite].Width;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   304
r.h:= SpritesData[Sprite].Height;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   305
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   306
if (X < LeftX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   307
    r.x:= LeftX - X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   308
if (Y < TopY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   309
    r.y:= TopY - Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   310
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   311
if (Y + SpritesData[Sprite].Height > BottomY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   312
    r.h:= BottomY - Y + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   313
if (X + SpritesData[Sprite].Width > RightX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   314
    r.w:= RightX - X + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   315
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   316
dec(r.h, r.y);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   317
dec(r.w, r.x);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   318
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   319
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   320
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   321
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   322
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   323
var scale: GLfloat;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   324
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   325
    if (Source^.w + 20) > cScreenWidth then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   326
        scale:= cScreenWidth / (Source^.w + 20)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   327
    else
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   328
        scale:= 1.0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   329
    DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   330
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   331
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   332
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   333
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   334
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   335
    glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   336
    glEnable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   337
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   338
    glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   339
    glTranslatef(WorldDx, WorldDy, 0);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   340
    glLineWidth(Width);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   341
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   342
    Tint(r, g, b, a);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   343
    VertexBuffer[0].X:= X0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   344
    VertexBuffer[0].Y:= Y0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   345
    VertexBuffer[1].X:= X1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   346
    VertexBuffer[1].Y:= Y1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   347
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   348
    glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   349
    glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   350
    Tint($FF, $FF, $FF, $FF);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   351
    
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   352
    glPopMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   353
    
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   354
    glEnable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   355
    glDisable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   356
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   357
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   358
procedure DrawFillRect(r: TSDL_Rect);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   359
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   360
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   361
// 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
   362
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
   363
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   364
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
   365
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   366
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   367
glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   368
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   369
Tint($00, $00, $00, $80);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   370
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   371
VertexBuffer[0].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   372
VertexBuffer[0].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   373
VertexBuffer[1].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   374
VertexBuffer[1].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   375
VertexBuffer[2].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   376
VertexBuffer[2].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   377
VertexBuffer[3].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   378
VertexBuffer[3].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   379
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   380
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   381
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   382
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   383
Tint($FF, $FF, $FF, $FF);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   384
glEnable(GL_TEXTURE_2D)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   385
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   386
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
   387
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
   388
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
   389
    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
   390
    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
   391
    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
   392
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
   393
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
   394
procedure DrawCircle(X, Y, Radius, Width: LongInt); 
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   395
var
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   396
    i: LongInt;
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   397
    CircleVertex: array [0..59] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   398
begin
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   399
    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
   400
        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
   401
        CircleVertex[i].Y := Y + Radius*sin(i*pi/30);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   402
    end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   403
    glDisable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   404
    glEnable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   405
    glPushMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   406
    glLineWidth(Width);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   407
    glVertexPointer(2, GL_FLOAT, 0, @CircleVertex[0]);
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   408
    glDrawArrays(GL_LINE_LOOP, 0, 60);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   409
    glPopMatrix;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   410
    glEnable(GL_TEXTURE_2D);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   411
    glDisable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   412
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   413
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   414
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   415
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   416
const VertexBuffer: array [0..3] of TVertex2f = (
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   417
        (X: -16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   418
        (X:  16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   419
        (X:  16; Y:  16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   420
        (X: -16; Y:  16));
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   421
var l, r, t, b: real;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   422
    TextureBuffer: array [0..3] of TVertex2f;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   423
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   424
    // 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
   425
    if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   426
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   427
    if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   428
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   429
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   430
    t:= Pos * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   431
    b:= (Pos + 1) * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   432
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   433
    if Dir = -1 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   434
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   435
        l:= (Step + 1) * 32 / HHTexture^.w;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   436
        r:= Step * 32 / HHTexture^.w
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   437
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   438
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   439
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   440
        l:= Step * 32 / HHTexture^.w;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   441
        r:= (Step + 1) * 32 / HHTexture^.w
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   442
    end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   443
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   444
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   445
    glPushMatrix();
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   446
    glTranslatef(X, Y, 0);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   447
    glRotatef(Angle, 0, 0, 1);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   448
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   449
    glBindTexture(GL_TEXTURE_2D, HHTexture^.id);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   450
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   451
    TextureBuffer[0].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   452
    TextureBuffer[0].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   453
    TextureBuffer[1].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   454
    TextureBuffer[1].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   455
    TextureBuffer[2].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   456
    TextureBuffer[2].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   457
    TextureBuffer[3].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   458
    TextureBuffer[3].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   459
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   460
    glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   461
    glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   462
    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   463
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   464
    glPopMatrix
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   465
end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   466
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   467
procedure DrawScreenWidget(widget: POnScreenWidget);
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   468
{$IFDEF USE_TOUCH_INTERFACE}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   469
var alpha: byte = $FF;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   470
begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   471
with widget^ do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   472
    begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   473
    if (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   474
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   475
        if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   476
            fadeAnimStart:= 0
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   477
        else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   478
            if show then 
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   479
                alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   480
            else 
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   481
                alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   482
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   483
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   484
    with moveAnim do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   485
        if animate then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   486
            if RealTicks > (startTime + MOVE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   487
                begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   488
                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
   489
                animate:= false;
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   490
                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
   491
                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
   492
                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
   493
                active.y:= active.y + (target.y - source.y);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   494
                end
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   495
            else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   496
                begin
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   497
                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
   498
                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
   499
                end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   500
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   501
    if show or (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   502
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   503
        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
   504
        DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   505
        Tint($FF, $FF, $FF, $FF);
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   506
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   507
    end;
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   508
{$ELSE}
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   509
begin
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   510
widget:= widget; // avoid hint
6689
98a239848ba2 wops, added an extra USE_TOUCH_INTERFACE
Xeli
parents: 6688
diff changeset
   511
{$ENDIF}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   512
end;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   513
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   514
procedure Tint(r, g, b, a: Byte); inline;
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6710
diff changeset
   515
var nc, tw: Longword;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   516
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
   517
    nc:= (a shl 24) or (b shl 16) or (g shl 8) or r;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
   518
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   519
    if nc = lastTint then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   520
        exit;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
   521
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   522
    if GrayScale then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   523
        begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   524
        tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   525
        if tw > 255 then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   526
            tw:= 255;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   527
        r:= tw;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   528
        g:= tw;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   529
        b:= tw
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   530
        end;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5235
diff changeset
   531
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   532
    glColor4ub(r, g, b, a);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   533
    lastTint:= nc;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   534
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   535
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   536
procedure Tint(c: Longword); inline;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   537
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
   538
    Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   539
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   540
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   541
end.