author | sheepluva |
Sat, 14 Jun 2014 00:56:11 +0200 | |
changeset 10301 | 6a225b469eef |
parent 10276 | 89056c7254ef |
child 10302 | ea0b0e2efd95 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
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 | 17 |
*) |
18 |
||
4378 | 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 | 21 |
|
4378 | 22 |
unit uRender; |
23 |
||
24 |
interface |
|
25 |
||
10015 | 26 |
uses SDLh, uTypes, GLunit, uConsts, uStore{$IFDEF GL2}, uMatrix{$ENDIF}; |
4378 | 27 |
|
6999 | 28 |
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
29 |
procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
|
8560 | 30 |
procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
6999 | 31 |
procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
32 |
procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
|
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 | 35 |
procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; |
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 | 38 |
procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
39 |
procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
|
40 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
|
6999 | 41 |
procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); |
42 |
procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
|
43 |
procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
|
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 | 46 |
procedure DrawCircle (X, Y, Radius, Width: LongInt); |
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 | 49 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
6999 | 50 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
51 |
procedure DrawFillRect (r: TSDL_Rect); |
|
52 |
procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
|
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 | 55 |
|
56 |
procedure Tint (r, g, b, a: Byte); inline; |
|
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 | 60 |
|
10266 | 61 |
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline; |
62 |
||
63 |
// 0 => not offscreen, <0 => left/top of screen >0 => right/below of screen |
|
64 |
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline; |
|
65 |
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline; |
|
66 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
67 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
68 |
procedure openglTranslProjMatrix(X, Y, Z: GLFloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
69 |
procedure openglPushMatrix (); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
70 |
procedure openglPopMatrix (); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
71 |
procedure openglTranslatef (X, Y, Z: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
72 |
procedure openglScalef (ScaleX, ScaleY, ScaleZ: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
73 |
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
|
74 |
procedure openglTint (r, g, b, a: Byte); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
75 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
76 |
|
4378 | 77 |
implementation |
78 |
uses uVariables; |
|
79 |
||
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
80 |
{$IFDEF USE_TOUCH_INTERFACE} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
81 |
const |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
82 |
FADE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
83 |
MOVE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
84 |
{$ENDIF} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
85 |
|
7028 | 86 |
var LastTint: LongWord = 0; |
87 |
||
10266 | 88 |
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline; |
89 |
begin |
|
90 |
isAreaOffscreen:= (isDxAreaOffscreen(X, Width) <> 0) or (isDyAreaOffscreen(Y, Height) <> 0); |
|
91 |
end; |
|
92 |
||
93 |
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline; |
|
94 |
begin |
|
95 |
if X > ViewRightX then exit(1); |
|
96 |
if X + Width < ViewLeftX then exit(-1); |
|
97 |
isDxAreaOffscreen:= 0; |
|
98 |
end; |
|
99 |
||
100 |
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline; |
|
101 |
begin |
|
102 |
if Y > ViewBottomY then exit(1); |
|
103 |
if Y + Height < ViewTopY then exit(-1); |
|
104 |
isDyAreaOffscreen:= 0; |
|
105 |
end; |
|
106 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
107 |
procedure openglTranslProjMatrix(X, Y, Z: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
108 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
109 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
110 |
hglMatrixMode(MATRIX_PROJECTION); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
111 |
hglTranslatef(X, Y, Z); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
112 |
hglMatrixMode(MATRIX_MODELVIEW); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
113 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
114 |
glMatrixMode(GL_PROJECTION); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
115 |
glTranslatef(X, Y, Z); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
116 |
glMatrixMode(GL_MODELVIEW); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
117 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
118 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
119 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
120 |
procedure openglPushMatrix(); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
121 |
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
|
122 |
{$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
|
123 |
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
|
124 |
{$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
|
125 |
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
|
126 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
127 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
128 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
129 |
procedure openglPopMatrix(); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
130 |
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
|
131 |
{$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
|
132 |
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
|
133 |
{$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
|
134 |
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
|
135 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
136 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
137 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
138 |
procedure openglTranslatef(X, Y, Z: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
139 |
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
|
140 |
{$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
|
141 |
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
|
142 |
{$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
|
143 |
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
|
144 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
145 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
146 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
147 |
procedure openglScalef(ScaleX, ScaleY, ScaleZ: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
148 |
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
|
149 |
{$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
|
150 |
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
|
151 |
{$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
|
152 |
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
|
153 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
154 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
155 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
{$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
|
159 |
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
|
160 |
{$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
|
161 |
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
|
162 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
163 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
164 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
165 |
procedure openglUseColorOnly(b :boolean); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
166 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
167 |
if b then |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
168 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
169 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
170 |
glDisableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
171 |
glEnableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
172 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
173 |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
174 |
glEnableClientState(GL_COLOR_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
175 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
176 |
end |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
177 |
else |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
178 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
179 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
180 |
glDisableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
181 |
glEnableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
182 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
183 |
glDisableClientState(GL_COLOR_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
184 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
185 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
186 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
187 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
188 |
|
8560 | 189 |
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
4378 | 190 |
begin |
191 |
r.y:= r.y + Height * Position; |
|
192 |
r.h:= Height; |
|
6999 | 193 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 194 |
end; |
195 |
||
8560 | 196 |
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
4378 | 197 |
begin |
8560 | 198 |
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1) |
199 |
end; |
|
8833 | 200 |
|
8560 | 201 |
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
202 |
begin |
|
203 |
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1) |
|
4378 | 204 |
end; |
205 |
||
8560 | 206 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
4378 | 207 |
var rr: TSDL_Rect; |
208 |
_l, _r, _t, _b: real; |
|
209 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
210 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
211 |
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
|
212 |
exit; |
4378 | 213 |
|
5565 | 214 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 215 |
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then |
216 |
exit; |
|
217 |
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then |
|
218 |
exit; |
|
219 |
||
220 |
rr.x:= X; |
|
221 |
rr.y:= Y; |
|
222 |
rr.w:= W; |
|
223 |
rr.h:= H; |
|
224 |
||
225 |
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx; |
|
226 |
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx; |
|
227 |
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry; |
|
228 |
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry; |
|
229 |
||
230 |
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
|
231 |
||
8560 | 232 |
if Dir < 0 then |
233 |
begin |
|
234 |
VertexBuffer[0].X:= X + rr.w/2; |
|
235 |
VertexBuffer[0].Y:= Y; |
|
236 |
VertexBuffer[1].X:= X - rr.w/2; |
|
237 |
VertexBuffer[1].Y:= Y; |
|
238 |
VertexBuffer[2].X:= X - rr.w/2; |
|
239 |
VertexBuffer[2].Y:= rr.h + Y; |
|
240 |
VertexBuffer[3].X:= X + rr.w/2; |
|
241 |
VertexBuffer[3].Y:= rr.h + Y; |
|
242 |
end |
|
243 |
else |
|
244 |
begin |
|
245 |
VertexBuffer[0].X:= X; |
|
246 |
VertexBuffer[0].Y:= Y; |
|
247 |
VertexBuffer[1].X:= rr.w + X; |
|
248 |
VertexBuffer[1].Y:= Y; |
|
249 |
VertexBuffer[2].X:= rr.w + X; |
|
250 |
VertexBuffer[2].Y:= rr.h + Y; |
|
251 |
VertexBuffer[3].X:= X; |
|
252 |
VertexBuffer[3].Y:= rr.h + Y; |
|
253 |
end; |
|
4378 | 254 |
|
255 |
TextureBuffer[0].X:= _l; |
|
256 |
TextureBuffer[0].Y:= _t; |
|
257 |
TextureBuffer[1].X:= _r; |
|
258 |
TextureBuffer[1].Y:= _t; |
|
259 |
TextureBuffer[2].X:= _r; |
|
260 |
TextureBuffer[2].Y:= _b; |
|
261 |
TextureBuffer[3].X:= _l; |
|
262 |
TextureBuffer[3].Y:= _b; |
|
263 |
||
264 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
265 |
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
|
266 |
glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1); |
4378 | 267 |
end; |
268 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
269 |
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
|
270 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
271 |
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
|
272 |
end; |
4378 | 273 |
|
274 |
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
|
275 |
begin |
|
276 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
277 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
278 |
openglTranslatef(X, Y, 0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
279 |
openglScalef(Scale, Scale, 1); |
4378 | 280 |
|
281 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
282 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
283 |
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
|
284 |
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
|
285 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
286 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
287 |
UpdateModelviewProjection; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
288 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
289 |
|
4378 | 290 |
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
|
291 |
openglPopMatrix; |
4378 | 292 |
|
293 |
end; |
|
294 |
||
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
295 |
{ 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
|
296 |
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
|
297 |
var |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
298 |
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
|
299 |
begin |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
300 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
301 |
openglTranslatef(X, Y, 0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
302 |
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
|
303 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
304 |
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
|
305 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
306 |
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
|
307 |
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
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
|
10266 | 315 |
SetVertexPointer(@Texture^.vb, Length(Texture^.vb)); |
316 |
SetTexCoordPointer(@TextureBuffer, Length(Texture^.vb)); |
|
317 |
||
318 |
{$IFDEF GL2} |
|
319 |
UpdateModelviewProjection; |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
320 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
321 |
|
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
322 |
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
|
323 |
openglPopMatrix; |
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
324 |
end; |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
325 |
|
4378 | 326 |
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
327 |
begin |
|
6999 | 328 |
DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
4378 | 329 |
end; |
330 |
||
6999 | 331 |
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
4378 | 332 |
var ft, fb, fl, fr: GLfloat; |
10301 | 333 |
hw, hh, nx, ny: LongInt; |
4378 | 334 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
335 |
begin |
|
5565 | 336 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 337 |
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then |
338 |
exit; |
|
339 |
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then |
|
340 |
exit; |
|
341 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
342 |
openglPushMatrix; |
10301 | 343 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
344 |
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
|
345 |
|
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
|
346 |
if Dir = 0 then Dir:= 1; |
4378 | 347 |
|
10301 | 348 |
if Angle <> 0 then |
349 |
openglRotatef(Angle, 0, 0, Dir); |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
350 |
|
10301 | 351 |
if (OffsetX <> 0) or (OffsetY <> 0) then |
352 |
openglTranslatef(Dir*OffsetX, OffsetY, 0); |
|
353 |
||
354 |
if Scale <> 1.0 then |
|
355 |
openglScalef(Scale, Scale, 1); |
|
4378 | 356 |
|
357 |
// Any reason for this call? And why only in t direction, not s? |
|
358 |
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
359 |
||
10301 | 360 |
if Dir > 0 then |
361 |
hw:= w div 2 |
|
362 |
else |
|
363 |
hw:= -w div 2; |
|
4378 | 364 |
|
10301 | 365 |
hh:= h div 2; |
366 |
||
367 |
nx:= Texture^.w div w; // number of horizontal frames |
|
368 |
ny:= Texture^.h div h; // number of vertical frames |
|
4378 | 369 |
|
370 |
ft:= (Frame mod ny) * Texture^.ry / ny; |
|
371 |
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
|
372 |
fl:= (Frame div ny) * Texture^.rx / nx; |
|
373 |
fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
|
374 |
||
375 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
376 |
||
377 |
VertexBuffer[0].X:= -hw; |
|
10301 | 378 |
VertexBuffer[0].Y:= -hh; |
379 |
VertexBuffer[1].X:= hw; |
|
380 |
VertexBuffer[1].Y:= -hh; |
|
381 |
VertexBuffer[2].X:= hw; |
|
382 |
VertexBuffer[2].Y:= hh; |
|
4378 | 383 |
VertexBuffer[3].X:= -hw; |
10301 | 384 |
VertexBuffer[3].Y:= hh; |
4378 | 385 |
|
386 |
TextureBuffer[0].X:= fl; |
|
387 |
TextureBuffer[0].Y:= ft; |
|
388 |
TextureBuffer[1].X:= fr; |
|
389 |
TextureBuffer[1].Y:= ft; |
|
390 |
TextureBuffer[2].X:= fr; |
|
391 |
TextureBuffer[2].Y:= fb; |
|
392 |
TextureBuffer[3].X:= fl; |
|
393 |
TextureBuffer[3].Y:= fb; |
|
394 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
395 |
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
|
396 |
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
|
397 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
398 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
399 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
400 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
401 |
|
4378 | 402 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
403 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
404 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
405 |
|
4378 | 406 |
end; |
407 |
||
6999 | 408 |
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
4378 | 409 |
begin |
6999 | 410 |
DrawTextureRotated(SpritesData[Sprite].Texture, |
4378 | 411 |
SpritesData[Sprite].Width, |
412 |
SpritesData[Sprite].Height, |
|
413 |
X, Y, Dir, Angle) |
|
414 |
end; |
|
415 |
||
6999 | 416 |
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
4378 | 417 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
418 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
419 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
420 |
openglTranslatef(X, Y, 0); |
4378 | 421 |
|
422 |
if Dir < 0 then |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
423 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
424 |
openglRotatef(Angle, 0, 0, -1); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
425 |
openglScalef(-1.0, 1.0, 1.0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
426 |
end |
4378 | 427 |
else |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
428 |
openglRotatef(Angle, 0, 0, 1); |
4378 | 429 |
|
430 |
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); |
|
431 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
432 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
433 |
|
4378 | 434 |
end; |
435 |
||
6999 | 436 |
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
4378 | 437 |
var VertexBuffer: array [0..3] of TVertex2f; |
438 |
begin |
|
5565 | 439 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 440 |
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then |
441 |
exit; |
|
442 |
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then |
|
443 |
exit; |
|
444 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
445 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
446 |
openglTranslatef(X, Y, 0); |
4378 | 447 |
|
448 |
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
|
449 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
450 |
hw:= - hw; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
451 |
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
|
452 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
453 |
else |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
454 |
openglRotatef(Angle, 0, 0, 1); |
4378 | 455 |
|
6999 | 456 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
4378 | 457 |
|
458 |
VertexBuffer[0].X:= -hw; |
|
459 |
VertexBuffer[0].Y:= -hh; |
|
460 |
VertexBuffer[1].X:= hw; |
|
461 |
VertexBuffer[1].Y:= -hh; |
|
462 |
VertexBuffer[2].X:= hw; |
|
463 |
VertexBuffer[2].Y:= hh; |
|
464 |
VertexBuffer[3].X:= -hw; |
|
465 |
VertexBuffer[3].Y:= hh; |
|
466 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
467 |
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
|
468 |
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
|
469 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
470 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
471 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
472 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
473 |
|
4378 | 474 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
475 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
476 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
477 |
|
4378 | 478 |
end; |
479 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
480 |
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
4378 | 481 |
var row, col, numFramesFirstCol: LongInt; |
482 |
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
|
483 |
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
|
484 |
exit; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
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
|
489 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
490 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
491 |
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
|
492 |
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
|
493 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
494 |
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
|
495 |
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
|
496 |
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
|
497 |
r.h:= SpritesData[Sprite].Height; |
6999 | 498 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 499 |
end; |
500 |
||
501 |
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
|
502 |
var r: TSDL_Rect; |
|
503 |
begin |
|
504 |
r.x:= 0; |
|
505 |
r.y:= 0; |
|
506 |
r.w:= SpritesData[Sprite].Width; |
|
507 |
r.h:= SpritesData[Sprite].Height; |
|
508 |
||
509 |
if (X < LeftX) then |
|
510 |
r.x:= LeftX - X; |
|
511 |
if (Y < TopY) then |
|
512 |
r.y:= TopY - Y; |
|
513 |
||
514 |
if (Y + SpritesData[Sprite].Height > BottomY) then |
|
515 |
r.h:= BottomY - Y + 1; |
|
516 |
if (X + SpritesData[Sprite].Width > RightX) then |
|
517 |
r.w:= RightX - X + 1; |
|
518 |
||
10015 | 519 |
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
|
520 |
exit; |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
521 |
|
4378 | 522 |
dec(r.h, r.y); |
523 |
dec(r.w, r.x); |
|
524 |
||
6999 | 525 |
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
4378 | 526 |
end; |
527 |
||
6999 | 528 |
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); |
4378 | 529 |
var scale: GLfloat; |
530 |
begin |
|
531 |
if (Source^.w + 20) > cScreenWidth then |
|
532 |
scale:= cScreenWidth / (Source^.w + 20) |
|
533 |
else |
|
534 |
scale:= 1.0; |
|
535 |
DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale) |
|
536 |
end; |
|
537 |
||
9557 | 538 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
539 |
begin |
|
540 |
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
|
541 |
end; |
|
542 |
||
4378 | 543 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
8626 | 544 |
var VertexBuffer: array [0..1] of TVertex2f; |
4378 | 545 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
546 |
glEnable(GL_LINE_SMOOTH); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
547 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
548 |
EnableTexture(False); |
4378 | 549 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
550 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
551 |
openglTranslatef(WorldDx, WorldDy, 0); |
4378 | 552 |
glLineWidth(Width); |
553 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
554 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
555 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
556 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
557 |
|
4378 | 558 |
Tint(r, g, b, a); |
559 |
VertexBuffer[0].X:= X0; |
|
560 |
VertexBuffer[0].Y:= Y0; |
|
561 |
VertexBuffer[1].X:= X1; |
|
562 |
VertexBuffer[1].Y:= Y1; |
|
563 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
564 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 565 |
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
|
566 |
untint; |
10015 | 567 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
568 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
569 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
570 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
571 |
|
4378 | 572 |
glDisable(GL_LINE_SMOOTH); |
573 |
end; |
|
574 |
||
575 |
procedure DrawFillRect(r: TSDL_Rect); |
|
576 |
var VertexBuffer: array [0..3] of TVertex2f; |
|
577 |
begin |
|
5565 | 578 |
// 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
|
579 |
|
4378 | 580 |
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then |
581 |
exit; |
|
582 |
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then |
|
583 |
exit; |
|
584 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
585 |
EnableTexture(False); |
4378 | 586 |
|
587 |
Tint($00, $00, $00, $80); |
|
588 |
||
589 |
VertexBuffer[0].X:= r.x; |
|
590 |
VertexBuffer[0].Y:= r.y; |
|
591 |
VertexBuffer[1].X:= r.x + r.w; |
|
592 |
VertexBuffer[1].Y:= r.y; |
|
593 |
VertexBuffer[2].X:= r.x + r.w; |
|
594 |
VertexBuffer[2].Y:= r.y + r.h; |
|
595 |
VertexBuffer[3].X:= r.x; |
|
596 |
VertexBuffer[3].Y:= r.y + r.h; |
|
597 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
598 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 599 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
600 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
601 |
untint; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
602 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
603 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
604 |
|
4378 | 605 |
end; |
606 |
||
8330 | 607 |
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
|
608 |
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
|
609 |
Tint(r, g, b, a); |
10015 | 610 |
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
|
611 |
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
|
612 |
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
|
613 |
|
8330 | 614 |
procedure DrawCircle(X, Y, Radius, Width: LongInt); |
4378 | 615 |
var |
616 |
i: LongInt; |
|
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
617 |
CircleVertex: array [0..59] of TVertex2f; |
4378 | 618 |
begin |
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
619 |
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
|
620 |
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
|
621 |
CircleVertex[i].Y := Y + Radius*sin(i*pi/30); |
4378 | 622 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
623 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
624 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
625 |
glEnable(GL_LINE_SMOOTH); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
626 |
openglPushMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
627 |
glLineWidth(Width); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
628 |
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
|
629 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
630 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
631 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
632 |
glDisable(GL_LINE_SMOOTH); |
4378 | 633 |
end; |
634 |
||
635 |
||
4385 | 636 |
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
637 |
const VertexBuffer: array [0..3] of TVertex2f = ( |
|
7069 | 638 |
(X: -16; Y: -16), |
639 |
(X: 16; Y: -16), |
|
640 |
(X: 16; Y: 16), |
|
641 |
(X: -16; Y: 16)); |
|
4385 | 642 |
var l, r, t, b: real; |
643 |
TextureBuffer: array [0..3] of TVertex2f; |
|
644 |
begin |
|
5565 | 645 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4385 | 646 |
if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then |
647 |
exit; |
|
648 |
if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then |
|
649 |
exit; |
|
650 |
||
651 |
t:= Pos * 32 / HHTexture^.h; |
|
652 |
b:= (Pos + 1) * 32 / HHTexture^.h; |
|
653 |
||
654 |
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
|
655 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
656 |
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
|
657 |
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
|
658 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
659 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
660 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
661 |
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
|
662 |
r:= (Step + 1) * 32 / HHTexture^.w |
4385 | 663 |
end; |
664 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
665 |
openglPushMatrix(); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
666 |
openglTranslatef(X, Y, 0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
667 |
openglRotatef(Angle, 0, 0, 1); |
4385 | 668 |
|
669 |
glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
670 |
||
671 |
TextureBuffer[0].X:= l; |
|
672 |
TextureBuffer[0].Y:= t; |
|
673 |
TextureBuffer[1].X:= r; |
|
674 |
TextureBuffer[1].Y:= t; |
|
675 |
TextureBuffer[2].X:= r; |
|
676 |
TextureBuffer[2].Y:= b; |
|
677 |
TextureBuffer[3].X:= l; |
|
678 |
TextureBuffer[3].Y:= b; |
|
679 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
680 |
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
|
681 |
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
|
682 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
683 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
684 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
685 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
686 |
|
4385 | 687 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
688 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
689 |
openglPopMatrix; |
4385 | 690 |
end; |
691 |
||
6688 | 692 |
procedure DrawScreenWidget(widget: POnScreenWidget); |
6992 | 693 |
{$IFDEF USE_TOUCH_INTERFACE} |
6688 | 694 |
var alpha: byte = $FF; |
695 |
begin |
|
696 |
with widget^ do |
|
697 |
begin |
|
698 |
if (fadeAnimStart <> 0) then |
|
699 |
begin |
|
700 |
if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then |
|
701 |
fadeAnimStart:= 0 |
|
702 |
else |
|
8330 | 703 |
if show then |
6688 | 704 |
alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) |
8330 | 705 |
else |
6688 | 706 |
alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); |
707 |
end; |
|
708 |
||
709 |
with moveAnim do |
|
710 |
if animate then |
|
711 |
if RealTicks > (startTime + MOVE_ANIM_TIME) then |
|
712 |
begin |
|
713 |
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
|
714 |
animate:= false; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
active.y:= active.y + (target.y - source.y); |
6688 | 719 |
end |
720 |
else |
|
721 |
begin |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
722 |
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
|
723 |
frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); |
6688 | 724 |
end; |
725 |
||
726 |
if show or (fadeAnimStart <> 0) then |
|
727 |
begin |
|
728 |
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
|
729 |
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
|
730 |
untint; |
6688 | 731 |
end; |
732 |
end; |
|
6992 | 733 |
{$ELSE} |
734 |
begin |
|
735 |
widget:= widget; // avoid hint |
|
6689 | 736 |
{$ENDIF} |
6688 | 737 |
end; |
4385 | 738 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
739 |
procedure BeginWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
740 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
741 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
742 |
glUseProgram(shaderWater); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
743 |
uCurrentMVPLocation:=uWaterMVPLocation; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
744 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
745 |
glDisableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
746 |
glEnableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
747 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
748 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
749 |
openglUseColorOnly(true); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
750 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
751 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
752 |
procedure EndWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
753 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
754 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
755 |
glUseProgram(shaderMain); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
756 |
uCurrentMVPLocation:=uMainMVPLocation; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
757 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
758 |
glDisableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
759 |
glEnableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
760 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
761 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
762 |
openglUseColorOnly(false); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
763 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
764 |
|
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
|
765 |
procedure DrawWaterBody(pVertexBuffer: Pointer); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
766 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
767 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
768 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
769 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
770 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
771 |
BeginWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
772 |
if SuddenDeathDmg then |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
773 |
SetColorPointer(@SDWaterColorArray[0], 4) |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
774 |
else |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
775 |
SetColorPointer(@WaterColorArray[0], 4); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
776 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
777 |
SetVertexPointer(pVertexBuffer, 4); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
778 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
779 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
780 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
781 |
EndWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
782 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
783 |
|
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
784 |
procedure openglTint(r, g, b, a: Byte); inline; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
785 |
{$IFDEF GL2} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
786 |
const |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
787 |
scale:Real = 1.0/255.0; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
788 |
{$ENDIF} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
789 |
begin |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
790 |
{$IFDEF GL2} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
791 |
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
|
792 |
{$ELSE} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
793 |
glColor4ub(r, g, b, a); |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
794 |
{$ENDIF} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
795 |
end; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
796 |
|
4378 | 797 |
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
|
798 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
799 |
nc, tw: Longword; |
4378 | 800 |
begin |
9557 | 801 |
nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; |
5559 | 802 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
803 |
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
|
804 |
exit; |
5559 | 805 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
806 |
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
|
807 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
808 |
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
|
809 |
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
|
810 |
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
|
811 |
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
|
812 |
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
|
813 |
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
|
814 |
end; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
815 |
|
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
816 |
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
|
817 |
lastTint:= nc; |
4378 | 818 |
end; |
819 |
||
820 |
procedure Tint(c: Longword); inline; |
|
821 |
begin |
|
9557 | 822 |
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
|
823 |
Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) |
4378 | 824 |
end; |
825 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
826 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
827 |
begin |
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
828 |
if cWhiteColor = lastTint then exit; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
829 |
openglTint($FF, $FF, $FF, $FF); |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
830 |
lastTint:= cWhiteColor; |
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
831 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
832 |
|
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
833 |
procedure setTintAdd(f: boolean); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
834 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
835 |
if f then |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
836 |
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
|
837 |
else |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
838 |
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
|
839 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
840 |
|
4378 | 841 |
end. |