hedgewars/uRender.pas
author sheepluva
Sat, 14 Jun 2014 02:25:49 +0200
changeset 10302 ea0b0e2efd95
parent 10301 6a225b469eef
child 10304 7e40820b7ed6
permissions -rw-r--r--
huh? me? nono, don't mind me. I'm just here to clean up.
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
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9792
diff changeset
     3
 * Copyright (c) 2004-2014 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
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10040
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
4976
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"}
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
    20
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF}
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    21
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    22
unit uRender;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    23
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    24
interface
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    25
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    26
uses SDLh, uTypes, GLunit, uConsts{$IFDEF GL2}, uMatrix{$ENDIF};
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    27
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    28
procedure DrawSprite            (Sprite: TSprite; X, Y, Frame: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    29
procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    30
procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    31
procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    32
procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    33
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
    34
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    35
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    36
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
    37
procedure DrawTexture2          (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    38
procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    39
procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    40
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    41
procedure DrawTextureCentered   (X, Top: LongInt; Source: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    42
procedure DrawTextureF          (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    43
procedure DrawTextureRotated    (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    44
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
    45
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    46
procedure DrawCircle            (X, Y, Radius, Width: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    47
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
    48
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
    49
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    50
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    51
procedure DrawFillRect          (r: TSDL_Rect);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    52
procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    53
procedure DrawScreenWidget      (widget: POnScreenWidget);
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
    54
procedure DrawWaterBody         (pVertexBuffer: Pointer);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    55
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    56
procedure Tint                  (r, g, b, a: Byte); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    57
procedure Tint                  (c: Longword); inline;
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
    58
procedure untint(); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
    59
procedure setTintAdd            (f: boolean); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    60
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    61
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    62
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    63
// 0 => not offscreen, <0 => left/top of screen >0 => right/below of screen
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    64
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    65
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    66
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    67
procedure SetScale(f: GLfloat);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    68
procedure UpdateViewLimits();
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    69
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    70
procedure EnableTexture(enable:Boolean);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    71
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    72
procedure SetTexCoordPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    73
procedure SetVertexPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    74
procedure SetColorPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    75
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    76
procedure UpdateModelviewProjection(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    77
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    78
procedure openglLoadIdentity    (); inline;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    79
procedure openglTranslProjMatrix(X, Y, Z: GLFloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    80
procedure openglPushMatrix      (); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    81
procedure openglPopMatrix       (); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    82
procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    83
procedure openglScalef          (ScaleX, ScaleY, ScaleZ: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    84
procedure openglRotatef         (RotX, RotY, RotZ: GLfloat; dir: LongInt); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    85
procedure openglTint            (r, g, b, a: Byte); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    86
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    87
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    88
implementation
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    89
uses uVariables;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    90
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    91
{$IFDEF USE_TOUCH_INTERFACE}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    92
const
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    93
    FADE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    94
    MOVE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    95
{$ENDIF}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
    96
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
    97
var LastTint: LongWord = 0;
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
    98
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    99
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   100
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   101
    isAreaOffscreen:= (isDxAreaOffscreen(X, Width) <> 0) or (isDyAreaOffscreen(Y, Height) <> 0);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   102
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   103
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   104
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   105
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   106
    if X > ViewRightX then exit(1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   107
    if X + Width < ViewLeftX then exit(-1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   108
    isDxAreaOffscreen:= 0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   109
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   110
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   111
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   112
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   113
    if Y > ViewBottomY then exit(1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   114
    if Y + Height < ViewTopY then exit(-1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   115
    isDyAreaOffscreen:= 0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   116
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   117
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   118
procedure openglLoadIdentity(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   119
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   120
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   121
    hglLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   122
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   123
    glLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   124
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   125
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   126
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   127
procedure openglTranslProjMatrix(X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   128
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   129
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   130
    hglMatrixMode(MATRIX_PROJECTION);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   131
    hglTranslatef(X, Y, Z);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   132
    hglMatrixMode(MATRIX_MODELVIEW);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   133
{$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   134
    glMatrixMode(GL_PROJECTION);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   135
    glTranslatef(X, Y, Z);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   136
    glMatrixMode(GL_MODELVIEW);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   137
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   138
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   139
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   140
procedure openglPushMatrix(); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   141
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   142
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   143
    hglPushMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   144
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   145
    glPushMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   146
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   147
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   148
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   149
procedure openglPopMatrix(); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   150
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   151
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   152
    hglPopMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   153
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   154
    glPopMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   155
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   156
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   157
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   158
procedure openglTranslatef(X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   159
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   160
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   161
    hglTranslatef(X, Y, Z);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   162
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   163
    glTranslatef(X, Y, Z);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   164
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   165
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   166
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   167
procedure openglScalef(ScaleX, ScaleY, ScaleZ: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   168
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   169
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   170
    hglScalef(ScaleX, ScaleY, ScaleZ);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   171
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   172
    glScalef(ScaleX, ScaleY, ScaleZ);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   173
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   174
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   175
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   176
procedure openglRotatef(RotX, RotY, RotZ: GLfloat; dir: LongInt); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   177
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   178
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   179
    hglRotatef(RotX, RotY, RotZ, dir);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   180
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   181
    glRotatef(RotX, RotY, RotZ, dir);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   182
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   183
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   184
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   185
procedure openglUseColorOnly(b :boolean); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   186
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   187
    if b then
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   188
        begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   189
        {$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   190
        glDisableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   191
        glEnableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   192
        {$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   193
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   194
        glEnableClientState(GL_COLOR_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   195
        {$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   196
        end
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   197
    else
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   198
        begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   199
        {$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   200
        glDisableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   201
        glEnableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   202
        {$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   203
        glDisableClientState(GL_COLOR_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   204
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   205
        {$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   206
        end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   207
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   208
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   209
procedure UpdateModelviewProjection(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   210
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   211
var
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   212
    mvp: TMatrix4x4f;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   213
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   214
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   215
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   216
    //MatrixMultiply(mvp, mProjection, mModelview);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   217
{$HINTS OFF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   218
    hglMVP(mvp);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   219
{$HINTS ON}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   220
    glUniformMatrix4fv(uCurrentMVPLocation, 1, GL_FALSE, @mvp[0, 0]);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   221
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   222
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   223
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   224
procedure SetTexCoordPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   225
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   226
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   227
    glBindBuffer(GL_ARRAY_BUFFER, tBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   228
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   229
    glEnableVertexAttribArray(aTexCoord);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   230
    glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   231
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   232
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   233
    glTexCoordPointer(2, GL_FLOAT, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   234
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   235
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   236
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   237
procedure SetVertexPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   238
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   239
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   240
    glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   241
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   242
    glEnableVertexAttribArray(aVertex);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   243
    glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   244
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   245
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   246
    glVertexPointer(2, GL_FLOAT, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   247
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   248
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   249
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   250
procedure SetColorPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   251
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   252
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   253
    glBindBuffer(GL_ARRAY_BUFFER, cBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   254
    glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   255
    glEnableVertexAttribArray(aColor);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   256
    glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   257
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   258
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   259
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   260
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   261
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   262
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   263
procedure EnableTexture(enable:Boolean);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   264
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   265
    {$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   266
    if enable then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   267
        glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 1)
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   268
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   269
        glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 0);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   270
    {$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   271
    if enable then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   272
        glEnable(GL_TEXTURE_2D)
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   273
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   274
        glDisable(GL_TEXTURE_2D);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   275
    {$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   276
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   277
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   278
procedure UpdateViewLimits();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   279
var tmp: real;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   280
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   281
    // cScaleFactor is 2.0 on "no zoom"
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   282
    tmp:= cScreenWidth / cScaleFactor;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   283
    ViewRightX:= round(tmp); // ceil could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   284
    ViewLeftX:= round(-tmp); // floor could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   285
    tmp:= cScreenHeight / cScaleFactor;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   286
    ViewBottomY:= round(tmp) + cScreenHeight div 2; // ceil could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   287
    ViewTopY:= round(-tmp) + cScreenHeight div 2; // floor could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   288
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   289
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   290
procedure SetScale(f: GLfloat);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   291
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   292
// leave immediately if scale factor did not change
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   293
    if f = cScaleFactor then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   294
        exit;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   295
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   296
    // for going back to default scaling just pop matrix
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   297
    if f = cDefaultZoomLevel then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   298
        begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   299
        openglPopMatrix;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   300
        end
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   301
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   302
        begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   303
        openglPushMatrix; // save default scaling in matrix
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   304
        openglLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   305
        openglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   306
        openglTranslatef(0, -cScreenHeight / 2, 0);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   307
        end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   308
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   309
    cScaleFactor:= f;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   310
    updateViewLimits();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   311
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   312
    UpdateModelviewProjection;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   313
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   314
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   315
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   316
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   317
r.y:= r.y + Height * Position;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   318
r.h:= Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   319
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   320
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   321
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   322
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   323
begin
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   324
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1)
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   325
end;
8833
c13ebed437cb update webgl branch
koda
parents: 8330 8626
diff changeset
   326
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   327
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   328
begin
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   329
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   330
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   331
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   332
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   333
var rr: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   334
    _l, _r, _t, _b: real;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   335
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   336
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   337
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
   338
    exit;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   339
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   340
// 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
   341
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   342
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   343
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   344
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   345
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   346
rr.x:= X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   347
rr.y:= Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   348
rr.w:= W;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   349
rr.h:= H;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   350
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   351
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   352
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   353
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   354
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   355
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   356
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   357
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   358
if Dir < 0 then
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   359
    begin
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   360
    VertexBuffer[0].X:= X + rr.w/2;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   361
    VertexBuffer[0].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   362
    VertexBuffer[1].X:= X - rr.w/2;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   363
    VertexBuffer[1].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   364
    VertexBuffer[2].X:= X - rr.w/2;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   365
    VertexBuffer[2].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   366
    VertexBuffer[3].X:= X + rr.w/2;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   367
    VertexBuffer[3].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   368
    end
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   369
else
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   370
    begin
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   371
    VertexBuffer[0].X:= X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   372
    VertexBuffer[0].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   373
    VertexBuffer[1].X:= rr.w + X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   374
    VertexBuffer[1].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   375
    VertexBuffer[2].X:= rr.w + X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   376
    VertexBuffer[2].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   377
    VertexBuffer[3].X:= X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   378
    VertexBuffer[3].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   379
    end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   380
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   381
TextureBuffer[0].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   382
TextureBuffer[0].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   383
TextureBuffer[1].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   384
TextureBuffer[1].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   385
TextureBuffer[2].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   386
TextureBuffer[2].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   387
TextureBuffer[3].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   388
TextureBuffer[3].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   389
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   390
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   391
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   392
glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   393
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   394
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   395
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
   396
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   397
    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
   398
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   399
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   400
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   401
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   402
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   403
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   404
openglTranslatef(X, Y, 0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   405
openglScalef(Scale, Scale, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   406
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   407
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   408
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   409
SetVertexPointer(@Texture^.vb, Length(Texture^.vb));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   410
SetTexCoordPointer(@Texture^.tb, Length(Texture^.vb));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   411
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   412
{$IFDEF GL2}
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   413
UpdateModelviewProjection;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   414
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   415
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   416
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   417
openglPopMatrix;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   418
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   419
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   420
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   421
{ this contains tweaks in order to avoid land tile borders in blurry land mode }
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   422
procedure DrawTexture2(X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   423
var
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   424
    TextureBuffer: array [0..3] of TVertex2f;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   425
begin
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   426
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   427
openglTranslatef(X, Y, 0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   428
openglScalef(Scale, Scale, 1);
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   429
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   430
glBindTexture(GL_TEXTURE_2D, Texture^.id);
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   431
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   432
TextureBuffer[0].X:= Texture^.tb[0].X + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   433
TextureBuffer[0].Y:= Texture^.tb[0].Y + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   434
TextureBuffer[1].X:= Texture^.tb[1].X - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   435
TextureBuffer[1].Y:= Texture^.tb[1].Y + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   436
TextureBuffer[2].X:= Texture^.tb[2].X - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   437
TextureBuffer[2].Y:= Texture^.tb[2].Y - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   438
TextureBuffer[3].X:= Texture^.tb[3].X + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   439
TextureBuffer[3].Y:= Texture^.tb[3].Y - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   440
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   441
SetVertexPointer(@Texture^.vb, Length(Texture^.vb));
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   442
SetTexCoordPointer(@TextureBuffer, Length(Texture^.vb));
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   443
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   444
UpdateModelviewProjection;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   445
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   446
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   447
openglPopMatrix;
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   448
end;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   449
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   450
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   451
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   452
    DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   453
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   454
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   455
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
   456
var ft, fb, fl, fr: GLfloat;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   457
    hw, hh, nx, ny: LongInt;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   458
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   459
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   460
// 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
   461
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   462
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   463
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   464
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   465
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   466
openglPushMatrix;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   467
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   468
openglTranslatef(X, Y, 0);
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   469
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
   470
if Dir = 0 then Dir:= 1;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   471
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   472
if Angle <> 0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   473
    openglRotatef(Angle, 0, 0, Dir);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   474
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   475
if (OffsetX <> 0) or (OffsetY <> 0) then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   476
    openglTranslatef(Dir*OffsetX, OffsetY, 0);
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   477
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   478
if Scale <> 1.0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   479
    openglScalef(Scale, Scale, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   480
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   481
// Any reason for this call? And why only in t direction, not s?
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   482
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   483
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   484
if Dir > 0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   485
    hw:=  w div 2
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   486
else
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   487
    hw:= -w div 2;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   488
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   489
hh:= h div 2;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   490
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   491
nx:= Texture^.w div w; // number of horizontal frames
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   492
ny:= Texture^.h div h; // number of vertical frames
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   493
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   494
ft:= (Frame mod ny) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   495
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   496
fl:= (Frame div ny) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   497
fr:= ((Frame div ny) + 1) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   498
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   499
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   500
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   501
VertexBuffer[0].X:= -hw;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   502
VertexBuffer[0].Y:= -hh;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   503
VertexBuffer[1].X:=  hw;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   504
VertexBuffer[1].Y:= -hh;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   505
VertexBuffer[2].X:=  hw;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   506
VertexBuffer[2].Y:=  hh;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   507
VertexBuffer[3].X:= -hw;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   508
VertexBuffer[3].Y:=  hh;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   509
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   510
TextureBuffer[0].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   511
TextureBuffer[0].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   512
TextureBuffer[1].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   513
TextureBuffer[1].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   514
TextureBuffer[2].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   515
TextureBuffer[2].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   516
TextureBuffer[3].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   517
TextureBuffer[3].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   518
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   519
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   520
SetTexCoordPointer(@TextureBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   521
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   522
UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   523
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   524
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   525
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   526
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   527
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   528
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   529
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   530
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   531
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   532
    DrawTextureRotated(SpritesData[Sprite].Texture,
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   533
        SpritesData[Sprite].Width,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   534
        SpritesData[Sprite].Height,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   535
        X, Y, Dir, Angle)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   536
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   537
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   538
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   539
begin
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   540
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   541
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   542
openglTranslatef(X, Y, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   543
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   544
if Dir < 0 then
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   545
    begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   546
    openglRotatef(Angle, 0, 0, -1);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   547
    openglScalef(-1.0, 1.0, 1.0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   548
    end
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   549
else
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   550
    openglRotatef(Angle, 0, 0,  1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   551
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   552
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   553
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   554
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   555
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   556
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   557
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   558
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   559
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   560
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   561
// 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
   562
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   563
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   564
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   565
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   566
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   567
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   568
openglTranslatef(X, Y, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   569
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   570
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
   571
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   572
    hw:= - hw;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   573
    openglRotatef(Angle, 0, 0, -1);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   574
    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   575
else
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   576
    openglRotatef(Angle, 0, 0, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   577
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   578
glBindTexture(GL_TEXTURE_2D, Texture^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   579
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   580
VertexBuffer[0].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   581
VertexBuffer[0].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   582
VertexBuffer[1].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   583
VertexBuffer[1].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   584
VertexBuffer[2].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   585
VertexBuffer[2].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   586
VertexBuffer[3].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   587
VertexBuffer[3].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   588
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   589
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   590
SetTexCoordPointer(@Texture^.tb, Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   591
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   592
UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   593
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   594
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   595
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   596
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   597
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   598
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   599
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   600
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   601
var row, col, numFramesFirstCol: LongInt;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   602
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
   603
    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
   604
        exit;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   605
    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
   606
    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
   607
    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
   608
    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
   609
end;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   610
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   611
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
   612
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
   613
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   614
    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
   615
    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
   616
    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
   617
    r.h:= SpritesData[Sprite].Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   618
    DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   619
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   620
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   621
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   622
var r: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   623
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   624
r.x:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   625
r.y:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   626
r.w:= SpritesData[Sprite].Width;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   627
r.h:= SpritesData[Sprite].Height;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   628
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   629
if (X < LeftX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   630
    r.x:= LeftX - X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   631
if (Y < TopY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   632
    r.y:= TopY - Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   633
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   634
if (Y + SpritesData[Sprite].Height > BottomY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   635
    r.h:= BottomY - Y + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   636
if (X + SpritesData[Sprite].Width > RightX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   637
    r.w:= RightX - X + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   638
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
   639
if (r.h < r.y) or (r.w < r.x) then
9792
59cde1e53ca5 This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents: 9666
diff changeset
   640
    exit;
59cde1e53ca5 This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents: 9666
diff changeset
   641
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   642
dec(r.h, r.y);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   643
dec(r.w, r.x);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   644
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   645
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   646
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   647
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   648
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   649
var scale: GLfloat;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   650
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   651
    if (Source^.w + 20) > cScreenWidth then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   652
        scale:= cScreenWidth / (Source^.w + 20)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   653
    else
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   654
        scale:= 1.0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   655
    DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   656
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   657
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   658
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline;
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   659
begin
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   660
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF)
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   661
end;
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   662
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   663
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
8626
cfc44db21d72 Fix DrawLine bug
Urbertar@gmail.com
parents: 8560
diff changeset
   664
var VertexBuffer: array [0..1] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   665
begin
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   666
    glEnable(GL_LINE_SMOOTH);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   667
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   668
    EnableTexture(False);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   669
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   670
    openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   671
    openglTranslatef(WorldDx, WorldDy, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   672
    glLineWidth(Width);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   673
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   674
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   675
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   676
    Tint(r, g, b, a);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   677
    VertexBuffer[0].X:= X0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   678
    VertexBuffer[0].Y:= Y0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   679
    VertexBuffer[1].X:= X1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   680
    VertexBuffer[1].Y:= Y1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   681
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   682
    SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   683
    glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   684
    untint;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
   685
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   686
    openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   687
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   688
    EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   689
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   690
    glDisable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   691
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   692
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   693
procedure DrawFillRect(r: TSDL_Rect);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   694
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   695
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   696
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   697
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   698
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
   699
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   700
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
   701
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   702
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   703
EnableTexture(False);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   704
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   705
Tint($00, $00, $00, $80);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   706
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   707
VertexBuffer[0].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   708
VertexBuffer[0].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   709
VertexBuffer[1].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   710
VertexBuffer[1].Y:= r.y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   711
VertexBuffer[2].X:= r.x + r.w;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   712
VertexBuffer[2].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   713
VertexBuffer[3].X:= r.x;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   714
VertexBuffer[3].Y:= r.y + r.h;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   715
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   716
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   717
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   718
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   719
untint;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   720
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   721
EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   722
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   723
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   724
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
   725
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
   726
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
   727
    Tint(r, g, b, a);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
   728
    DrawCircle(X, Y, Radius, Width);
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   729
    untint;
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
   730
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
   731
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
   732
procedure DrawCircle(X, Y, Radius, Width: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   733
var
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   734
    i: LongInt;
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   735
    CircleVertex: array [0..59] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   736
begin
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
   737
    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
   738
        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
   739
        CircleVertex[i].Y := Y + Radius*sin(i*pi/30);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   740
    end;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   741
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   742
    EnableTexture(False);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   743
    glEnable(GL_LINE_SMOOTH);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   744
    openglPushMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   745
    glLineWidth(Width);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   746
    SetVertexPointer(@CircleVertex[0], 60);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   747
    glDrawArrays(GL_LINE_LOOP, 0, 60);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   748
    openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   749
    EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   750
    glDisable(GL_LINE_SMOOTH);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   751
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   752
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   753
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   754
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   755
const VertexBuffer: array [0..3] of TVertex2f = (
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   756
        (X: -16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   757
        (X:  16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   758
        (X:  16; Y:  16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   759
        (X: -16; Y:  16));
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   760
var l, r, t, b: real;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   761
    TextureBuffer: array [0..3] of TVertex2f;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   762
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   763
    // 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
   764
    if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   765
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   766
    if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   767
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   768
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   769
    t:= Pos * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   770
    b:= (Pos + 1) * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   771
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   772
    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
   773
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   774
        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
   775
        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
   776
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   777
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   778
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   779
        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
   780
        r:= (Step + 1) * 32 / HHTexture^.w
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   781
    end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   782
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   783
    openglPushMatrix();
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   784
    openglTranslatef(X, Y, 0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   785
    openglRotatef(Angle, 0, 0, 1);
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   786
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   787
    glBindTexture(GL_TEXTURE_2D, HHTexture^.id);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   788
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   789
    TextureBuffer[0].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   790
    TextureBuffer[0].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   791
    TextureBuffer[1].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   792
    TextureBuffer[1].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   793
    TextureBuffer[2].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   794
    TextureBuffer[2].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   795
    TextureBuffer[3].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   796
    TextureBuffer[3].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   797
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   798
    SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   799
    SetTexCoordPointer(@TextureBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   800
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   801
    UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   802
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   803
    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   804
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   805
    openglPopMatrix;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   806
end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   807
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   808
procedure DrawScreenWidget(widget: POnScreenWidget);
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   809
{$IFDEF USE_TOUCH_INTERFACE}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   810
var alpha: byte = $FF;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   811
begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   812
with widget^ do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   813
    begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   814
    if (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   815
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   816
        if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   817
            fadeAnimStart:= 0
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   818
        else
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
   819
            if show then
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   820
                alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
   821
            else
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   822
                alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   823
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   824
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   825
    with moveAnim do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   826
        if animate then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   827
            if RealTicks > (startTime + MOVE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   828
                begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   829
                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
   830
                animate:= false;
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   831
                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
   832
                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
   833
                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
   834
                active.y:= active.y + (target.y - source.y);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   835
                end
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   836
            else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   837
                begin
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
   838
                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
   839
                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
   840
                end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   841
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   842
    if show or (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   843
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   844
        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
   845
        DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   846
        untint;
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   847
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   848
    end;
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   849
{$ELSE}
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   850
begin
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
   851
widget:= widget; // avoid hint
6689
98a239848ba2 wops, added an extra USE_TOUCH_INTERFACE
Xeli
parents: 6688
diff changeset
   852
{$ENDIF}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
   853
end;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
   854
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   855
procedure BeginWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   856
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   857
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   858
    glUseProgram(shaderWater);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   859
    uCurrentMVPLocation:=uWaterMVPLocation;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   860
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   861
    glDisableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   862
    glEnableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   863
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   864
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   865
    openglUseColorOnly(true);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   866
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   867
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   868
procedure EndWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   869
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   870
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   871
    glUseProgram(shaderMain);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   872
    uCurrentMVPLocation:=uMainMVPLocation;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   873
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   874
    glDisableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   875
    glEnableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   876
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   877
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   878
    openglUseColorOnly(false);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   879
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   880
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   881
procedure DrawWaterBody(pVertexBuffer: Pointer);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   882
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   883
        UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   884
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   885
        BeginWater;
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   886
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   887
        if SuddenDeathDmg then
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   888
            SetColorPointer(@SDWaterColorArray[0], 4)
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   889
        else
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   890
            SetColorPointer(@WaterColorArray[0], 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   891
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   892
        SetVertexPointer(pVertexBuffer, 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   893
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   894
        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   895
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   896
        EndWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   897
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   898
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   899
procedure openglTint(r, g, b, a: Byte); inline;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   900
{$IFDEF GL2}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   901
const
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   902
    scale:Real = 1.0/255.0;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   903
{$ENDIF}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   904
begin
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   905
    {$IFDEF GL2}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   906
    glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   907
    {$ELSE}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   908
    glColor4ub(r, g, b, a);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   909
    {$ENDIF}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   910
end;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   911
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   912
procedure Tint(r, g, b, a: Byte); inline;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   913
var
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   914
    nc, tw: Longword;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   915
begin
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   916
    nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
   917
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   918
    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
   919
        exit;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
   920
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   921
    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
   922
        begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   923
        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
   924
        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
   925
            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
   926
        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
   927
        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
   928
        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
   929
        end;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5235
diff changeset
   930
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   931
    openglTint(r, g, b, a);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   932
    lastTint:= nc;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   933
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   934
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   935
procedure Tint(c: Longword); inline;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   936
begin
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   937
    if c = lastTint then exit;
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   938
    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
   939
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   940
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   941
procedure untint(); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   942
begin
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   943
    if cWhiteColor = lastTint then exit;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   944
    openglTint($FF, $FF, $FF, $FF);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
   945
    lastTint:= cWhiteColor;
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   946
end;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   947
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   948
procedure setTintAdd(f: boolean); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   949
begin
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   950
    if f then
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   951
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   952
    else
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   953
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   954
end;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
   955
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   956
end.