author | sheepluva |
Tue, 21 Jan 2014 01:38:06 +0100 | |
changeset 10031 | 9353632dc661 |
parent 10020 | 67e127027af6 |
child 10040 | 4ac87acbaed9 |
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
4378 | 19 |
{$INCLUDE "options.inc"} |
4976 | 20 |
|
4378 | 21 |
unit uRender; |
22 |
||
23 |
interface |
|
24 |
||
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
25 |
uses SDLh, uTypes, GLunit, uConsts; |
4378 | 26 |
|
6999 | 27 |
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
28 |
procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
|
8560 | 29 |
procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
6999 | 30 |
procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
31 |
procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
|
32 |
procedure DrawSpriteRotatedF (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
33 |
|
6999 | 34 |
procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; |
35 |
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
|
36 |
procedure DrawTexture2 (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat); |
8560 | 37 |
procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
38 |
procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
|
39 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
|
6999 | 40 |
procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); |
41 |
procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
|
42 |
procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
|
43 |
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
|
44 |
|
6999 | 45 |
procedure DrawCircle (X, Y, Radius, Width: LongInt); |
46 |
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
|
47 |
|
9557 | 48 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
6999 | 49 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
50 |
procedure DrawFillRect (r: TSDL_Rect); |
|
51 |
procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
|
52 |
procedure DrawScreenWidget (widget: POnScreenWidget); |
|
53 |
||
54 |
procedure Tint (r, g, b, a: Byte); inline; |
|
55 |
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
|
56 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
57 |
procedure setTintAdd (f: boolean); inline; |
4378 | 58 |
|
4385 | 59 |
|
4378 | 60 |
implementation |
61 |
uses uVariables; |
|
62 |
||
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
63 |
{$IFDEF USE_TOUCH_INTERFACE} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
64 |
const |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
65 |
FADE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
66 |
MOVE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
67 |
{$ENDIF} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
68 |
|
7028 | 69 |
var LastTint: LongWord = 0; |
70 |
||
8560 | 71 |
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
4378 | 72 |
begin |
73 |
r.y:= r.y + Height * Position; |
|
74 |
r.h:= Height; |
|
6999 | 75 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 76 |
end; |
77 |
||
8560 | 78 |
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
4378 | 79 |
begin |
8560 | 80 |
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1) |
81 |
end; |
|
82 |
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
|
83 |
begin |
|
84 |
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1) |
|
4378 | 85 |
end; |
86 |
||
8560 | 87 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
4378 | 88 |
var rr: TSDL_Rect; |
89 |
_l, _r, _t, _b: real; |
|
90 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
91 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
92 |
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
|
93 |
exit; |
4378 | 94 |
|
5565 | 95 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 96 |
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then |
97 |
exit; |
|
98 |
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then |
|
99 |
exit; |
|
100 |
||
101 |
rr.x:= X; |
|
102 |
rr.y:= Y; |
|
103 |
rr.w:= W; |
|
104 |
rr.h:= H; |
|
105 |
||
106 |
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx; |
|
107 |
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx; |
|
108 |
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry; |
|
109 |
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry; |
|
110 |
||
111 |
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
|
112 |
||
8560 | 113 |
if Dir < 0 then |
114 |
begin |
|
115 |
VertexBuffer[0].X:= X + rr.w/2; |
|
116 |
VertexBuffer[0].Y:= Y; |
|
117 |
VertexBuffer[1].X:= X - rr.w/2; |
|
118 |
VertexBuffer[1].Y:= Y; |
|
119 |
VertexBuffer[2].X:= X - rr.w/2; |
|
120 |
VertexBuffer[2].Y:= rr.h + Y; |
|
121 |
VertexBuffer[3].X:= X + rr.w/2; |
|
122 |
VertexBuffer[3].Y:= rr.h + Y; |
|
123 |
end |
|
124 |
else |
|
125 |
begin |
|
126 |
VertexBuffer[0].X:= X; |
|
127 |
VertexBuffer[0].Y:= Y; |
|
128 |
VertexBuffer[1].X:= rr.w + X; |
|
129 |
VertexBuffer[1].Y:= Y; |
|
130 |
VertexBuffer[2].X:= rr.w + X; |
|
131 |
VertexBuffer[2].Y:= rr.h + Y; |
|
132 |
VertexBuffer[3].X:= X; |
|
133 |
VertexBuffer[3].Y:= rr.h + Y; |
|
134 |
end; |
|
4378 | 135 |
|
136 |
TextureBuffer[0].X:= _l; |
|
137 |
TextureBuffer[0].Y:= _t; |
|
138 |
TextureBuffer[1].X:= _r; |
|
139 |
TextureBuffer[1].Y:= _t; |
|
140 |
TextureBuffer[2].X:= _r; |
|
141 |
TextureBuffer[2].Y:= _b; |
|
142 |
TextureBuffer[3].X:= _l; |
|
143 |
TextureBuffer[3].Y:= _b; |
|
144 |
||
145 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
146 |
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
|
147 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
148 |
end; |
|
149 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
150 |
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
|
151 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
152 |
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
|
153 |
end; |
4378 | 154 |
|
155 |
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
|
156 |
begin |
|
157 |
||
158 |
glPushMatrix; |
|
159 |
glTranslatef(X, Y, 0); |
|
160 |
glScalef(Scale, Scale, 1); |
|
161 |
||
162 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
163 |
||
164 |
glVertexPointer(2, GL_FLOAT, 0, @Texture^.vb); |
|
165 |
glTexCoordPointer(2, GL_FLOAT, 0, @Texture^.tb); |
|
166 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb)); |
|
167 |
||
168 |
glPopMatrix |
|
169 |
end; |
|
170 |
||
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
171 |
{ 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
|
172 |
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
|
173 |
var |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
174 |
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
|
175 |
begin |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
176 |
glPushMatrix(); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
177 |
glTranslatef(X, Y, 0); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
178 |
glScalef(Scale, Scale, 1); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
179 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
180 |
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
|
181 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
182 |
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
191 |
glVertexPointer(2, GL_FLOAT, 0, @Texture^.vb); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
192 |
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
193 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb)); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
194 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
195 |
glPopMatrix(); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
196 |
end; |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
197 |
|
4378 | 198 |
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
199 |
begin |
|
6999 | 200 |
DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
4378 | 201 |
end; |
202 |
||
6999 | 203 |
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
4378 | 204 |
var ft, fb, fl, fr: GLfloat; |
205 |
hw, nx, ny: LongInt; |
|
206 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
207 |
begin |
|
5565 | 208 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 209 |
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then |
210 |
exit; |
|
211 |
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then |
|
212 |
exit; |
|
213 |
||
214 |
glPushMatrix; |
|
215 |
glTranslatef(X, Y, 0); |
|
6323
c1aa6a3c84a7
Dir should not be 0, but set it to 1 if 0 in case I missed some other place this was done. Also correct cloud scaling.
nemo
parents:
6322
diff
changeset
|
216 |
if Dir = 0 then Dir:= 1; |
4378 | 217 |
|
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
|
218 |
glRotatef(Angle, 0, 0, Dir); |
4378 | 219 |
|
220 |
glTranslatef(Dir*OffsetX, OffsetY, 0); |
|
221 |
glScalef(Scale, Scale, 1); |
|
222 |
||
223 |
// Any reason for this call? And why only in t direction, not s? |
|
224 |
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
225 |
||
6322
b310f0bc8dde
If I'm going to be arbitrary about it, might as well go for the more minimal arbitrariness
nemo
parents:
6318
diff
changeset
|
226 |
hw:= w div (2 div Dir); |
4378 | 227 |
|
228 |
nx:= round(Texture^.w / w); // number of horizontal frames |
|
229 |
ny:= round(Texture^.h / h); // number of vertical frames |
|
230 |
||
231 |
ft:= (Frame mod ny) * Texture^.ry / ny; |
|
232 |
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
|
233 |
fl:= (Frame div ny) * Texture^.rx / nx; |
|
234 |
fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
|
235 |
||
236 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
237 |
||
238 |
VertexBuffer[0].X:= -hw; |
|
239 |
VertexBuffer[0].Y:= w / -2; |
|
240 |
VertexBuffer[1].X:= hw; |
|
241 |
VertexBuffer[1].Y:= w / -2; |
|
242 |
VertexBuffer[2].X:= hw; |
|
243 |
VertexBuffer[2].Y:= w / 2; |
|
244 |
VertexBuffer[3].X:= -hw; |
|
245 |
VertexBuffer[3].Y:= w / 2; |
|
246 |
||
247 |
TextureBuffer[0].X:= fl; |
|
248 |
TextureBuffer[0].Y:= ft; |
|
249 |
TextureBuffer[1].X:= fr; |
|
250 |
TextureBuffer[1].Y:= ft; |
|
251 |
TextureBuffer[2].X:= fr; |
|
252 |
TextureBuffer[2].Y:= fb; |
|
253 |
TextureBuffer[3].X:= fl; |
|
254 |
TextureBuffer[3].Y:= fb; |
|
255 |
||
256 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
257 |
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
|
258 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
259 |
||
260 |
glPopMatrix |
|
261 |
end; |
|
262 |
||
6999 | 263 |
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
4378 | 264 |
begin |
6999 | 265 |
DrawTextureRotated(SpritesData[Sprite].Texture, |
4378 | 266 |
SpritesData[Sprite].Width, |
267 |
SpritesData[Sprite].Height, |
|
268 |
X, Y, Dir, Angle) |
|
269 |
end; |
|
270 |
||
6999 | 271 |
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
4378 | 272 |
begin |
273 |
glPushMatrix; |
|
274 |
glTranslatef(X, Y, 0); |
|
275 |
||
276 |
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
|
277 |
glRotatef(Angle, 0, 0, -1) |
4378 | 278 |
else |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
279 |
glRotatef(Angle, 0, 0, 1); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
280 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
281 |
glScalef(-1.0, 1.0, 1.0); |
4378 | 282 |
|
283 |
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); |
|
284 |
||
285 |
glPopMatrix |
|
286 |
end; |
|
287 |
||
6999 | 288 |
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
4378 | 289 |
var VertexBuffer: array [0..3] of TVertex2f; |
290 |
begin |
|
5565 | 291 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 292 |
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then |
293 |
exit; |
|
294 |
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then |
|
295 |
exit; |
|
296 |
||
297 |
glPushMatrix; |
|
298 |
glTranslatef(X, Y, 0); |
|
299 |
||
300 |
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
|
301 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
302 |
hw:= - hw; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
303 |
glRotatef(Angle, 0, 0, -1); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
304 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
305 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
306 |
glRotatef(Angle, 0, 0, 1); |
4378 | 307 |
|
308 |
||
6999 | 309 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
4378 | 310 |
|
311 |
VertexBuffer[0].X:= -hw; |
|
312 |
VertexBuffer[0].Y:= -hh; |
|
313 |
VertexBuffer[1].X:= hw; |
|
314 |
VertexBuffer[1].Y:= -hh; |
|
315 |
VertexBuffer[2].X:= hw; |
|
316 |
VertexBuffer[2].Y:= hh; |
|
317 |
VertexBuffer[3].X:= -hw; |
|
318 |
VertexBuffer[3].Y:= hh; |
|
319 |
||
320 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
6999 | 321 |
glTexCoordPointer(2, GL_FLOAT, 0, @Texture^.tb); |
4378 | 322 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
323 |
||
324 |
glPopMatrix |
|
325 |
end; |
|
326 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
327 |
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
4378 | 328 |
var row, col, numFramesFirstCol: LongInt; |
329 |
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
|
330 |
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
|
331 |
exit; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
337 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
338 |
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
|
339 |
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
|
340 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
r.h:= SpritesData[Sprite].Height; |
6999 | 345 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 346 |
end; |
347 |
||
348 |
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
|
349 |
var r: TSDL_Rect; |
|
350 |
begin |
|
351 |
r.x:= 0; |
|
352 |
r.y:= 0; |
|
353 |
r.w:= SpritesData[Sprite].Width; |
|
354 |
r.h:= SpritesData[Sprite].Height; |
|
355 |
||
356 |
if (X < LeftX) then |
|
357 |
r.x:= LeftX - X; |
|
358 |
if (Y < TopY) then |
|
359 |
r.y:= TopY - Y; |
|
360 |
||
361 |
if (Y + SpritesData[Sprite].Height > BottomY) then |
|
362 |
r.h:= BottomY - Y + 1; |
|
363 |
if (X + SpritesData[Sprite].Width > RightX) then |
|
364 |
r.w:= RightX - X + 1; |
|
365 |
||
9792
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
366 |
if (r.h < r.y) or (r.w < r.x) then |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
367 |
exit; |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
368 |
|
4378 | 369 |
dec(r.h, r.y); |
370 |
dec(r.w, r.x); |
|
371 |
||
6999 | 372 |
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
4378 | 373 |
end; |
374 |
||
6999 | 375 |
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); |
4378 | 376 |
var scale: GLfloat; |
377 |
begin |
|
378 |
if (Source^.w + 20) > cScreenWidth then |
|
379 |
scale:= cScreenWidth / (Source^.w + 20) |
|
380 |
else |
|
381 |
scale:= 1.0; |
|
382 |
DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale) |
|
383 |
end; |
|
384 |
||
9557 | 385 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
386 |
begin |
|
387 |
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
|
388 |
end; |
|
389 |
||
4378 | 390 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
8626 | 391 |
var VertexBuffer: array [0..1] of TVertex2f; |
4378 | 392 |
begin |
393 |
glDisable(GL_TEXTURE_2D); |
|
394 |
glEnable(GL_LINE_SMOOTH); |
|
395 |
||
396 |
glPushMatrix; |
|
397 |
glTranslatef(WorldDx, WorldDy, 0); |
|
398 |
glLineWidth(Width); |
|
399 |
||
400 |
Tint(r, g, b, a); |
|
401 |
VertexBuffer[0].X:= X0; |
|
402 |
VertexBuffer[0].Y:= Y0; |
|
403 |
VertexBuffer[1].X:= X1; |
|
404 |
VertexBuffer[1].Y:= Y1; |
|
405 |
||
406 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
407 |
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
|
408 |
untint; |
4378 | 409 |
|
410 |
glPopMatrix; |
|
411 |
||
412 |
glEnable(GL_TEXTURE_2D); |
|
413 |
glDisable(GL_LINE_SMOOTH); |
|
414 |
end; |
|
415 |
||
416 |
procedure DrawFillRect(r: TSDL_Rect); |
|
417 |
var VertexBuffer: array [0..3] of TVertex2f; |
|
418 |
begin |
|
5565 | 419 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 420 |
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then |
421 |
exit; |
|
422 |
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then |
|
423 |
exit; |
|
424 |
||
425 |
glDisable(GL_TEXTURE_2D); |
|
426 |
||
427 |
Tint($00, $00, $00, $80); |
|
428 |
||
429 |
VertexBuffer[0].X:= r.x; |
|
430 |
VertexBuffer[0].Y:= r.y; |
|
431 |
VertexBuffer[1].X:= r.x + r.w; |
|
432 |
VertexBuffer[1].Y:= r.y; |
|
433 |
VertexBuffer[2].X:= r.x + r.w; |
|
434 |
VertexBuffer[2].Y:= r.y + r.h; |
|
435 |
VertexBuffer[3].X:= r.x; |
|
436 |
VertexBuffer[3].Y:= r.y + r.h; |
|
437 |
||
438 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
439 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
440 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
441 |
untint; |
4378 | 442 |
glEnable(GL_TEXTURE_2D) |
443 |
end; |
|
444 |
||
4420
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4385
diff
changeset
|
445 |
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
|
446 |
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
|
447 |
Tint(r, g, b, a); |
1c342980b4aa
trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents:
4420
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
|
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
|
452 |
procedure DrawCircle(X, Y, Radius, Width: LongInt); |
4378 | 453 |
var |
454 |
i: LongInt; |
|
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
455 |
CircleVertex: array [0..59] of TVertex2f; |
4378 | 456 |
begin |
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
457 |
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
|
458 |
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
|
459 |
CircleVertex[i].Y := Y + Radius*sin(i*pi/30); |
4378 | 460 |
end; |
461 |
glDisable(GL_TEXTURE_2D); |
|
462 |
glEnable(GL_LINE_SMOOTH); |
|
463 |
glPushMatrix; |
|
464 |
glLineWidth(Width); |
|
465 |
glVertexPointer(2, GL_FLOAT, 0, @CircleVertex[0]); |
|
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
466 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
4378 | 467 |
glPopMatrix; |
468 |
glEnable(GL_TEXTURE_2D); |
|
469 |
glDisable(GL_LINE_SMOOTH); |
|
470 |
end; |
|
471 |
||
472 |
||
4385 | 473 |
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
474 |
const VertexBuffer: array [0..3] of TVertex2f = ( |
|
7069 | 475 |
(X: -16; Y: -16), |
476 |
(X: 16; Y: -16), |
|
477 |
(X: 16; Y: 16), |
|
478 |
(X: -16; Y: 16)); |
|
4385 | 479 |
var l, r, t, b: real; |
480 |
TextureBuffer: array [0..3] of TVertex2f; |
|
481 |
begin |
|
5565 | 482 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4385 | 483 |
if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then |
484 |
exit; |
|
485 |
if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then |
|
486 |
exit; |
|
487 |
||
488 |
t:= Pos * 32 / HHTexture^.h; |
|
489 |
b:= (Pos + 1) * 32 / HHTexture^.h; |
|
490 |
||
491 |
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
|
492 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
496 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
497 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
498 |
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
|
499 |
r:= (Step + 1) * 32 / HHTexture^.w |
4385 | 500 |
end; |
501 |
||
502 |
||
503 |
glPushMatrix(); |
|
504 |
glTranslatef(X, Y, 0); |
|
505 |
glRotatef(Angle, 0, 0, 1); |
|
506 |
||
507 |
glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
508 |
||
509 |
TextureBuffer[0].X:= l; |
|
510 |
TextureBuffer[0].Y:= t; |
|
511 |
TextureBuffer[1].X:= r; |
|
512 |
TextureBuffer[1].Y:= t; |
|
513 |
TextureBuffer[2].X:= r; |
|
514 |
TextureBuffer[2].Y:= b; |
|
515 |
TextureBuffer[3].X:= l; |
|
516 |
TextureBuffer[3].Y:= b; |
|
517 |
||
518 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
519 |
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
|
520 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
521 |
||
522 |
glPopMatrix |
|
523 |
end; |
|
524 |
||
6688 | 525 |
procedure DrawScreenWidget(widget: POnScreenWidget); |
6992 | 526 |
{$IFDEF USE_TOUCH_INTERFACE} |
6688 | 527 |
var alpha: byte = $FF; |
528 |
begin |
|
529 |
with widget^ do |
|
530 |
begin |
|
531 |
if (fadeAnimStart <> 0) then |
|
532 |
begin |
|
533 |
if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then |
|
534 |
fadeAnimStart:= 0 |
|
535 |
else |
|
536 |
if show then |
|
537 |
alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) |
|
538 |
else |
|
539 |
alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); |
|
540 |
end; |
|
541 |
||
542 |
with moveAnim do |
|
543 |
if animate then |
|
544 |
if RealTicks > (startTime + MOVE_ANIM_TIME) then |
|
545 |
begin |
|
546 |
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
|
547 |
animate:= false; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
548 |
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
|
549 |
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
|
550 |
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
|
551 |
active.y:= active.y + (target.y - source.y); |
6688 | 552 |
end |
553 |
else |
|
554 |
begin |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
555 |
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
|
556 |
frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); |
6688 | 557 |
end; |
558 |
||
559 |
if show or (fadeAnimStart <> 0) then |
|
560 |
begin |
|
561 |
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
|
562 |
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
|
563 |
untint; |
6688 | 564 |
end; |
565 |
end; |
|
6992 | 566 |
{$ELSE} |
567 |
begin |
|
568 |
widget:= widget; // avoid hint |
|
6689 | 569 |
{$ENDIF} |
6688 | 570 |
end; |
4385 | 571 |
|
4378 | 572 |
procedure Tint(r, g, b, a: Byte); inline; |
6982 | 573 |
var nc, tw: Longword; |
4378 | 574 |
begin |
9557 | 575 |
nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; |
5559 | 576 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
577 |
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
|
578 |
exit; |
5559 | 579 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
580 |
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
|
581 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
end; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
589 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
590 |
glColor4ub(r, g, b, a); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
591 |
lastTint:= nc; |
4378 | 592 |
end; |
593 |
||
594 |
procedure Tint(c: Longword); inline; |
|
595 |
begin |
|
9557 | 596 |
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
|
597 |
Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) |
4378 | 598 |
end; |
599 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
600 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
601 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
602 |
Tint($FF, $FF, $FF, $FF) |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
603 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
604 |
|
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
605 |
procedure setTintAdd(f: boolean); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
606 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
607 |
if f then |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
608 |
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
|
609 |
else |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
610 |
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
|
611 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
612 |
|
4378 | 613 |
end. |