author | unc0rr |
Sat, 04 Jan 2014 23:55:54 +0400 | |
branch | webgl |
changeset 9950 | 2759212a27de |
parent 9264 | 21df1a0ec9ed |
parent 9792 | 59cde1e53ca5 |
child 10015 | 4feced261c68 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9080 | 3 |
* Copyright (c) 2004-2013 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"} |
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 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
26 |
uses SDLh, uTypes, GLunit, uConsts, uStore, uMatrix; |
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); |
|
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 |
|
59 |
implementation |
|
60 |
uses uVariables; |
|
61 |
||
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
62 |
{$IFDEF USE_TOUCH_INTERFACE} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
63 |
const |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
64 |
FADE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
65 |
MOVE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
66 |
{$ENDIF} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
67 |
|
7028 | 68 |
var LastTint: LongWord = 0; |
69 |
||
8560 | 70 |
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
4378 | 71 |
begin |
72 |
r.y:= r.y + Height * Position; |
|
73 |
r.h:= Height; |
|
6999 | 74 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 75 |
end; |
76 |
||
8560 | 77 |
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
4378 | 78 |
begin |
8560 | 79 |
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1) |
80 |
end; |
|
8833 | 81 |
|
8560 | 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]); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
147 |
glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1); |
4378 | 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 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
158 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
159 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
160 |
hglTranslatef(X, Y, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
161 |
hglScalef(Scale, Scale, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
162 |
{$ELSE} |
4378 | 163 |
glPushMatrix; |
164 |
glTranslatef(X, Y, 0); |
|
165 |
glScalef(Scale, Scale, 1); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
166 |
{$ENDIF} |
4378 | 167 |
|
168 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
169 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
170 |
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
|
171 |
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
|
172 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
173 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
174 |
UpdateModelviewProjection; |
4378 | 175 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb)); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
176 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
177 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
178 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
179 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
180 |
{$ENDIF} |
4378 | 181 |
|
182 |
end; |
|
183 |
||
184 |
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
|
185 |
begin |
|
6999 | 186 |
DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
4378 | 187 |
end; |
188 |
||
6999 | 189 |
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
4378 | 190 |
var ft, fb, fl, fr: GLfloat; |
191 |
hw, nx, ny: LongInt; |
|
192 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
193 |
begin |
|
5565 | 194 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 195 |
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then |
196 |
exit; |
|
197 |
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then |
|
198 |
exit; |
|
199 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
200 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
201 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
202 |
hglTranslatef(X, Y, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
203 |
{$ELSE} |
4378 | 204 |
glPushMatrix; |
205 |
glTranslatef(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
|
206 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
207 |
|
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
|
208 |
if Dir = 0 then Dir:= 1; |
4378 | 209 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
210 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
211 |
hglRotatef(Angle, 0, 0, Dir); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
212 |
hglTranslatef(Dir*OffsetX, OffsetY, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
213 |
hglScalef(Scale, Scale, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
214 |
{$ELSE} |
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
|
215 |
glRotatef(Angle, 0, 0, Dir); |
4378 | 216 |
glTranslatef(Dir*OffsetX, OffsetY, 0); |
217 |
glScalef(Scale, Scale, 1); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
218 |
{$ENDIF} |
4378 | 219 |
|
220 |
// Any reason for this call? And why only in t direction, not s? |
|
221 |
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
222 |
||
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
|
223 |
hw:= w div (2 div Dir); |
4378 | 224 |
|
225 |
nx:= round(Texture^.w / w); // number of horizontal frames |
|
226 |
ny:= round(Texture^.h / h); // number of vertical frames |
|
227 |
||
228 |
ft:= (Frame mod ny) * Texture^.ry / ny; |
|
229 |
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
|
230 |
fl:= (Frame div ny) * Texture^.rx / nx; |
|
231 |
fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
|
232 |
||
233 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
234 |
||
235 |
VertexBuffer[0].X:= -hw; |
|
236 |
VertexBuffer[0].Y:= w / -2; |
|
237 |
VertexBuffer[1].X:= hw; |
|
238 |
VertexBuffer[1].Y:= w / -2; |
|
239 |
VertexBuffer[2].X:= hw; |
|
240 |
VertexBuffer[2].Y:= w / 2; |
|
241 |
VertexBuffer[3].X:= -hw; |
|
242 |
VertexBuffer[3].Y:= w / 2; |
|
243 |
||
244 |
TextureBuffer[0].X:= fl; |
|
245 |
TextureBuffer[0].Y:= ft; |
|
246 |
TextureBuffer[1].X:= fr; |
|
247 |
TextureBuffer[1].Y:= ft; |
|
248 |
TextureBuffer[2].X:= fr; |
|
249 |
TextureBuffer[2].Y:= fb; |
|
250 |
TextureBuffer[3].X:= fl; |
|
251 |
TextureBuffer[3].Y:= fb; |
|
252 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
253 |
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
|
254 |
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
|
255 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
256 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
257 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
258 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
259 |
|
4378 | 260 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
261 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
262 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
263 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
264 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
265 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
266 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
267 |
|
4378 | 268 |
end; |
269 |
||
6999 | 270 |
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
4378 | 271 |
begin |
6999 | 272 |
DrawTextureRotated(SpritesData[Sprite].Texture, |
4378 | 273 |
SpritesData[Sprite].Width, |
274 |
SpritesData[Sprite].Height, |
|
275 |
X, Y, Dir, Angle) |
|
276 |
end; |
|
277 |
||
6999 | 278 |
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
4378 | 279 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
280 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
281 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
282 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
283 |
hglTranslatef(X, Y, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
284 |
{$ELSE} |
4378 | 285 |
glPushMatrix; |
286 |
glTranslatef(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
|
287 |
{$ENDIF} |
4378 | 288 |
|
289 |
if Dir < 0 then |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
290 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
291 |
hglRotatef(Angle, 0, 0, -1) |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
292 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
293 |
glRotatef(Angle, 0, 0, -1) |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
294 |
{$ENDIF} |
4378 | 295 |
else |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
296 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
297 |
hglRotatef(Angle, 0, 0, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
298 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
299 |
glRotatef(Angle, 0, 0, 1); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
300 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
301 |
if Dir < 0 then |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
302 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
303 |
hglScalef(-1.0, 1.0, 1.0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
304 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
305 |
glScalef(-1.0, 1.0, 1.0); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
306 |
{$ENDIF} |
4378 | 307 |
|
308 |
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); |
|
309 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
310 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
311 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
312 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
313 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
314 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
315 |
|
4378 | 316 |
end; |
317 |
||
6999 | 318 |
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
4378 | 319 |
var VertexBuffer: array [0..3] of TVertex2f; |
320 |
begin |
|
5565 | 321 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 322 |
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then |
323 |
exit; |
|
324 |
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then |
|
325 |
exit; |
|
326 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
327 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
328 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
329 |
hglTranslatef(X, Y, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
330 |
{$ELSE} |
4378 | 331 |
glPushMatrix; |
332 |
glTranslatef(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
|
333 |
{$ENDIF} |
4378 | 334 |
|
335 |
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
|
336 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
337 |
hw:= - hw; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
338 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
339 |
hglRotatef(Angle, 0, 0, -1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
340 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
341 |
glRotatef(Angle, 0, 0, -1); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
342 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
343 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
344 |
else |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
345 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
346 |
hglRotatef(Angle, 0, 0, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
347 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
348 |
glRotatef(Angle, 0, 0, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
349 |
{$ENDIF} |
4378 | 350 |
|
6999 | 351 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
4378 | 352 |
|
353 |
VertexBuffer[0].X:= -hw; |
|
354 |
VertexBuffer[0].Y:= -hh; |
|
355 |
VertexBuffer[1].X:= hw; |
|
356 |
VertexBuffer[1].Y:= -hh; |
|
357 |
VertexBuffer[2].X:= hw; |
|
358 |
VertexBuffer[2].Y:= hh; |
|
359 |
VertexBuffer[3].X:= -hw; |
|
360 |
VertexBuffer[3].Y:= hh; |
|
361 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
362 |
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
|
363 |
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
|
364 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
365 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
366 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
367 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
368 |
|
4378 | 369 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
370 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
371 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
372 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
373 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
374 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
375 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
376 |
|
4378 | 377 |
end; |
378 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
379 |
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
4378 | 380 |
var row, col, numFramesFirstCol: LongInt; |
381 |
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
|
382 |
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
|
383 |
exit; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
384 |
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
|
385 |
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
|
386 |
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
|
387 |
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
|
388 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
389 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
390 |
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
|
391 |
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
|
392 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
393 |
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
|
394 |
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
|
395 |
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
|
396 |
r.h:= SpritesData[Sprite].Height; |
6999 | 397 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 398 |
end; |
399 |
||
400 |
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
|
401 |
var r: TSDL_Rect; |
|
402 |
begin |
|
403 |
r.x:= 0; |
|
404 |
r.y:= 0; |
|
405 |
r.w:= SpritesData[Sprite].Width; |
|
406 |
r.h:= SpritesData[Sprite].Height; |
|
407 |
||
408 |
if (X < LeftX) then |
|
409 |
r.x:= LeftX - X; |
|
410 |
if (Y < TopY) then |
|
411 |
r.y:= TopY - Y; |
|
412 |
||
413 |
if (Y + SpritesData[Sprite].Height > BottomY) then |
|
414 |
r.h:= BottomY - Y + 1; |
|
415 |
if (X + SpritesData[Sprite].Width > RightX) then |
|
416 |
r.w:= RightX - X + 1; |
|
417 |
||
9792
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
418 |
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
|
419 |
exit; |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
420 |
|
4378 | 421 |
dec(r.h, r.y); |
422 |
dec(r.w, r.x); |
|
423 |
||
6999 | 424 |
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
4378 | 425 |
end; |
426 |
||
6999 | 427 |
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); |
4378 | 428 |
var scale: GLfloat; |
429 |
begin |
|
430 |
if (Source^.w + 20) > cScreenWidth then |
|
431 |
scale:= cScreenWidth / (Source^.w + 20) |
|
432 |
else |
|
433 |
scale:= 1.0; |
|
434 |
DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale) |
|
435 |
end; |
|
436 |
||
9557 | 437 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
438 |
begin |
|
439 |
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
|
440 |
end; |
|
441 |
||
4378 | 442 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
8626 | 443 |
var VertexBuffer: array [0..1] of TVertex2f; |
4378 | 444 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
445 |
glEnable(GL_LINE_SMOOTH); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
446 |
{$IFNDEF GL2} |
4378 | 447 |
glDisable(GL_TEXTURE_2D); |
448 |
||
449 |
glPushMatrix; |
|
450 |
glTranslatef(WorldDx, WorldDy, 0); |
|
451 |
glLineWidth(Width); |
|
452 |
||
453 |
Tint(r, g, b, a); |
|
454 |
VertexBuffer[0].X:= X0; |
|
455 |
VertexBuffer[0].Y:= Y0; |
|
456 |
VertexBuffer[1].X:= X1; |
|
457 |
VertexBuffer[1].Y:= Y1; |
|
458 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
459 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 460 |
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
|
461 |
untint; |
4378 | 462 |
|
463 |
glPopMatrix; |
|
8330 | 464 |
|
4378 | 465 |
glEnable(GL_TEXTURE_2D); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
466 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
467 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
468 |
EnableTexture(False); |
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 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
471 |
hglTranslatef(WorldDx, WorldDy, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
472 |
glLineWidth(Width); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
473 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
474 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
475 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
476 |
Tint(r, g, b, a); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
477 |
VertexBuffer[0].X:= X0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
478 |
VertexBuffer[0].Y:= Y0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
479 |
VertexBuffer[1].X:= X1; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
480 |
VertexBuffer[1].Y:= Y1; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
481 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
482 |
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
|
483 |
glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
484 |
Tint($FF, $FF, $FF, $FF); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
485 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
486 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
487 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
488 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
489 |
{$ENDIF} |
4378 | 490 |
glDisable(GL_LINE_SMOOTH); |
491 |
end; |
|
492 |
||
493 |
procedure DrawFillRect(r: TSDL_Rect); |
|
494 |
var VertexBuffer: array [0..3] of TVertex2f; |
|
495 |
begin |
|
5565 | 496 |
// 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
|
497 |
|
4378 | 498 |
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then |
499 |
exit; |
|
500 |
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then |
|
501 |
exit; |
|
502 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
503 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
504 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
505 |
{$ELSE} |
4378 | 506 |
glDisable(GL_TEXTURE_2D); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
507 |
{$ENDIF} |
4378 | 508 |
|
509 |
Tint($00, $00, $00, $80); |
|
510 |
||
511 |
VertexBuffer[0].X:= r.x; |
|
512 |
VertexBuffer[0].Y:= r.y; |
|
513 |
VertexBuffer[1].X:= r.x + r.w; |
|
514 |
VertexBuffer[1].Y:= r.y; |
|
515 |
VertexBuffer[2].X:= r.x + r.w; |
|
516 |
VertexBuffer[2].Y:= r.y + r.h; |
|
517 |
VertexBuffer[3].X:= r.x; |
|
518 |
VertexBuffer[3].Y:= r.y + r.h; |
|
519 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
520 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 521 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
522 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
523 |
untint; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
524 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
525 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
526 |
{$ELSE} |
4378 | 527 |
glEnable(GL_TEXTURE_2D) |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
528 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
529 |
|
4378 | 530 |
end; |
531 |
||
8330 | 532 |
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
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
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
|
537 |
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
|
538 |
|
8330 | 539 |
procedure DrawCircle(X, Y, Radius, Width: LongInt); |
4378 | 540 |
var |
541 |
i: LongInt; |
|
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
542 |
CircleVertex: array [0..59] of TVertex2f; |
4378 | 543 |
begin |
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
544 |
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
|
545 |
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
|
546 |
CircleVertex[i].Y := Y + Radius*sin(i*pi/30); |
4378 | 547 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
548 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
549 |
{$IFNDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
550 |
|
4378 | 551 |
glDisable(GL_TEXTURE_2D); |
552 |
glEnable(GL_LINE_SMOOTH); |
|
553 |
glPushMatrix; |
|
554 |
glLineWidth(Width); |
|
555 |
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
|
556 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
4378 | 557 |
glPopMatrix; |
558 |
glEnable(GL_TEXTURE_2D); |
|
559 |
glDisable(GL_LINE_SMOOTH); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
560 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
561 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
562 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
563 |
glEnable(GL_LINE_SMOOTH); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
564 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
565 |
glLineWidth(Width); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
566 |
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
|
567 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
568 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
569 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
570 |
glDisable(GL_LINE_SMOOTH); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
571 |
{$ENDIF} |
4378 | 572 |
end; |
573 |
||
574 |
||
4385 | 575 |
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
576 |
const VertexBuffer: array [0..3] of TVertex2f = ( |
|
7069 | 577 |
(X: -16; Y: -16), |
578 |
(X: 16; Y: -16), |
|
579 |
(X: 16; Y: 16), |
|
580 |
(X: -16; Y: 16)); |
|
4385 | 581 |
var l, r, t, b: real; |
582 |
TextureBuffer: array [0..3] of TVertex2f; |
|
583 |
begin |
|
5565 | 584 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4385 | 585 |
if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then |
586 |
exit; |
|
587 |
if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then |
|
588 |
exit; |
|
589 |
||
590 |
t:= Pos * 32 / HHTexture^.h; |
|
591 |
b:= (Pos + 1) * 32 / HHTexture^.h; |
|
592 |
||
593 |
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
|
594 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
595 |
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
|
596 |
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
|
597 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
598 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
599 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
600 |
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
|
601 |
r:= (Step + 1) * 32 / HHTexture^.w |
4385 | 602 |
end; |
603 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
604 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
605 |
hglPushMatrix(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
606 |
hglTranslatef(X, Y, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
607 |
hglRotatef(Angle, 0, 0, 1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
608 |
{$ELSE} |
4385 | 609 |
glPushMatrix(); |
610 |
glTranslatef(X, Y, 0); |
|
611 |
glRotatef(Angle, 0, 0, 1); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
612 |
{$ENDIF} |
4385 | 613 |
|
614 |
glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
615 |
||
616 |
TextureBuffer[0].X:= l; |
|
617 |
TextureBuffer[0].Y:= t; |
|
618 |
TextureBuffer[1].X:= r; |
|
619 |
TextureBuffer[1].Y:= t; |
|
620 |
TextureBuffer[2].X:= r; |
|
621 |
TextureBuffer[2].Y:= b; |
|
622 |
TextureBuffer[3].X:= l; |
|
623 |
TextureBuffer[3].Y:= b; |
|
624 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
625 |
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
|
626 |
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
|
627 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
628 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
629 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
630 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
631 |
|
4385 | 632 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
633 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
634 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
635 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
636 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
637 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
638 |
{$ENDIF} |
4385 | 639 |
end; |
640 |
||
6688 | 641 |
procedure DrawScreenWidget(widget: POnScreenWidget); |
6992 | 642 |
{$IFDEF USE_TOUCH_INTERFACE} |
6688 | 643 |
var alpha: byte = $FF; |
644 |
begin |
|
645 |
with widget^ do |
|
646 |
begin |
|
647 |
if (fadeAnimStart <> 0) then |
|
648 |
begin |
|
649 |
if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then |
|
650 |
fadeAnimStart:= 0 |
|
651 |
else |
|
8330 | 652 |
if show then |
6688 | 653 |
alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) |
8330 | 654 |
else |
6688 | 655 |
alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); |
656 |
end; |
|
657 |
||
658 |
with moveAnim do |
|
659 |
if animate then |
|
660 |
if RealTicks > (startTime + MOVE_ANIM_TIME) then |
|
661 |
begin |
|
662 |
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
|
663 |
animate:= false; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
active.y:= active.y + (target.y - source.y); |
6688 | 668 |
end |
669 |
else |
|
670 |
begin |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
671 |
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
|
672 |
frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); |
6688 | 673 |
end; |
674 |
||
675 |
if show or (fadeAnimStart <> 0) then |
|
676 |
begin |
|
677 |
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
|
678 |
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
|
679 |
untint; |
6688 | 680 |
end; |
681 |
end; |
|
6992 | 682 |
{$ELSE} |
683 |
begin |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
684 |
{widget:= widget; // avoid hint} |
6689 | 685 |
{$ENDIF} |
6688 | 686 |
end; |
4385 | 687 |
|
4378 | 688 |
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
|
689 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
690 |
nc, tw: Longword; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
691 |
scale:Real = 1.0/255.0; |
4378 | 692 |
begin |
9557 | 693 |
nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; |
5559 | 694 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
695 |
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
|
696 |
exit; |
5559 | 697 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
698 |
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
|
699 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
700 |
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
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
end; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
707 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
708 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
709 |
glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
710 |
//glColor4ub(r, g, b, a); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
711 |
{$ELSE} |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
712 |
glColor4ub(r, g, b, a); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
713 |
{$ENDIF} |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
714 |
lastTint:= nc; |
4378 | 715 |
end; |
716 |
||
717 |
procedure Tint(c: Longword); inline; |
|
718 |
begin |
|
9557 | 719 |
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
|
720 |
Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) |
4378 | 721 |
end; |
722 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
723 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
724 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
725 |
Tint($FF, $FF, $FF, $FF) |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
726 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
727 |
|
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
728 |
procedure setTintAdd(f: boolean); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
729 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
730 |
if f then |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
731 |
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
|
732 |
else |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
733 |
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
|
734 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
735 |
|
4378 | 736 |
end. |