author | koda |
Fri, 24 Jan 2014 10:56:22 +0100 | |
changeset 10068 | cbe06dc07332 |
parent 10040 | 4ac87acbaed9 |
child 10108 | c68cf030eded |
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"} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
20 |
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF} |
4976 | 21 |
|
4378 | 22 |
unit uRender; |
23 |
||
24 |
interface |
|
25 |
||
10015 | 26 |
uses SDLh, uTypes, GLunit, uConsts, uStore{$IFDEF GL2}, uMatrix{$ENDIF}; |
4378 | 27 |
|
6999 | 28 |
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
29 |
procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
|
8560 | 30 |
procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
6999 | 31 |
procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
32 |
procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
|
33 |
procedure DrawSpriteRotatedF (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
34 |
|
6999 | 35 |
procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; |
36 |
procedure DrawTexture (X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
|
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
37 |
procedure DrawTexture2 (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat); |
8560 | 38 |
procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
39 |
procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
|
40 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
|
6999 | 41 |
procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); |
42 |
procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
|
43 |
procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
|
44 |
procedure DrawTextureRotatedF (Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
45 |
|
6999 | 46 |
procedure DrawCircle (X, Y, Radius, Width: LongInt); |
47 |
procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
48 |
|
9557 | 49 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
6999 | 50 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
51 |
procedure DrawFillRect (r: TSDL_Rect); |
|
52 |
procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
|
53 |
procedure DrawScreenWidget (widget: POnScreenWidget); |
|
54 |
||
55 |
procedure Tint (r, g, b, a: Byte); inline; |
|
56 |
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
|
57 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
58 |
procedure setTintAdd (f: boolean); inline; |
4378 | 59 |
|
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; |
|
8833 | 82 |
|
8560 | 83 |
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
84 |
begin |
|
85 |
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1) |
|
4378 | 86 |
end; |
87 |
||
8560 | 88 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
4378 | 89 |
var rr: TSDL_Rect; |
90 |
_l, _r, _t, _b: real; |
|
91 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
92 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
93 |
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
|
94 |
exit; |
4378 | 95 |
|
5565 | 96 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 97 |
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then |
98 |
exit; |
|
99 |
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then |
|
100 |
exit; |
|
101 |
||
102 |
rr.x:= X; |
|
103 |
rr.y:= Y; |
|
104 |
rr.w:= W; |
|
105 |
rr.h:= H; |
|
106 |
||
107 |
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx; |
|
108 |
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx; |
|
109 |
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry; |
|
110 |
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry; |
|
111 |
||
112 |
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
|
113 |
||
8560 | 114 |
if Dir < 0 then |
115 |
begin |
|
116 |
VertexBuffer[0].X:= X + rr.w/2; |
|
117 |
VertexBuffer[0].Y:= Y; |
|
118 |
VertexBuffer[1].X:= X - rr.w/2; |
|
119 |
VertexBuffer[1].Y:= Y; |
|
120 |
VertexBuffer[2].X:= X - rr.w/2; |
|
121 |
VertexBuffer[2].Y:= rr.h + Y; |
|
122 |
VertexBuffer[3].X:= X + rr.w/2; |
|
123 |
VertexBuffer[3].Y:= rr.h + Y; |
|
124 |
end |
|
125 |
else |
|
126 |
begin |
|
127 |
VertexBuffer[0].X:= X; |
|
128 |
VertexBuffer[0].Y:= Y; |
|
129 |
VertexBuffer[1].X:= rr.w + X; |
|
130 |
VertexBuffer[1].Y:= Y; |
|
131 |
VertexBuffer[2].X:= rr.w + X; |
|
132 |
VertexBuffer[2].Y:= rr.h + Y; |
|
133 |
VertexBuffer[3].X:= X; |
|
134 |
VertexBuffer[3].Y:= rr.h + Y; |
|
135 |
end; |
|
4378 | 136 |
|
137 |
TextureBuffer[0].X:= _l; |
|
138 |
TextureBuffer[0].Y:= _t; |
|
139 |
TextureBuffer[1].X:= _r; |
|
140 |
TextureBuffer[1].Y:= _t; |
|
141 |
TextureBuffer[2].X:= _r; |
|
142 |
TextureBuffer[2].Y:= _b; |
|
143 |
TextureBuffer[3].X:= _l; |
|
144 |
TextureBuffer[3].Y:= _b; |
|
145 |
||
146 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
147 |
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
|
148 |
glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1); |
4378 | 149 |
end; |
150 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
151 |
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
|
152 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
153 |
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
|
154 |
end; |
4378 | 155 |
|
156 |
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
|
157 |
begin |
|
158 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
159 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
160 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
{$ELSE} |
4378 | 164 |
glPushMatrix; |
165 |
glTranslatef(X, Y, 0); |
|
166 |
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
|
167 |
{$ENDIF} |
4378 | 168 |
|
169 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
170 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
174 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
175 |
UpdateModelviewProjection; |
4378 | 176 |
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
|
177 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
178 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
179 |
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
|
180 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
181 |
{$ENDIF} |
4378 | 182 |
|
183 |
end; |
|
184 |
||
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
185 |
{ 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
|
186 |
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
|
187 |
var |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
188 |
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
|
189 |
begin |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
190 |
glPushMatrix(); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
191 |
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
|
192 |
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
|
193 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
194 |
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
|
195 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
196 |
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
|
197 |
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
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
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
|
202 |
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
|
203 |
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
|
204 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
209 |
glPopMatrix(); |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
210 |
end; |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
211 |
|
4378 | 212 |
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
213 |
begin |
|
6999 | 214 |
DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
4378 | 215 |
end; |
216 |
||
6999 | 217 |
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
4378 | 218 |
var ft, fb, fl, fr: GLfloat; |
219 |
hw, nx, ny: LongInt; |
|
220 |
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
221 |
begin |
|
5565 | 222 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 223 |
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then |
224 |
exit; |
|
225 |
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then |
|
226 |
exit; |
|
227 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
228 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
229 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
230 |
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
|
231 |
{$ELSE} |
4378 | 232 |
glPushMatrix; |
233 |
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
|
234 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
235 |
|
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
|
236 |
if Dir = 0 then Dir:= 1; |
4378 | 237 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
238 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
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
|
242 |
{$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
|
243 |
glRotatef(Angle, 0, 0, Dir); |
4378 | 244 |
glTranslatef(Dir*OffsetX, OffsetY, 0); |
245 |
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
|
246 |
{$ENDIF} |
4378 | 247 |
|
248 |
// Any reason for this call? And why only in t direction, not s? |
|
249 |
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
250 |
||
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
|
251 |
hw:= w div (2 div Dir); |
4378 | 252 |
|
253 |
nx:= round(Texture^.w / w); // number of horizontal frames |
|
254 |
ny:= round(Texture^.h / h); // number of vertical frames |
|
255 |
||
256 |
ft:= (Frame mod ny) * Texture^.ry / ny; |
|
257 |
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
|
258 |
fl:= (Frame div ny) * Texture^.rx / nx; |
|
259 |
fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
|
260 |
||
261 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
262 |
||
263 |
VertexBuffer[0].X:= -hw; |
|
264 |
VertexBuffer[0].Y:= w / -2; |
|
265 |
VertexBuffer[1].X:= hw; |
|
266 |
VertexBuffer[1].Y:= w / -2; |
|
267 |
VertexBuffer[2].X:= hw; |
|
268 |
VertexBuffer[2].Y:= w / 2; |
|
269 |
VertexBuffer[3].X:= -hw; |
|
270 |
VertexBuffer[3].Y:= w / 2; |
|
271 |
||
272 |
TextureBuffer[0].X:= fl; |
|
273 |
TextureBuffer[0].Y:= ft; |
|
274 |
TextureBuffer[1].X:= fr; |
|
275 |
TextureBuffer[1].Y:= ft; |
|
276 |
TextureBuffer[2].X:= fr; |
|
277 |
TextureBuffer[2].Y:= fb; |
|
278 |
TextureBuffer[3].X:= fl; |
|
279 |
TextureBuffer[3].Y:= fb; |
|
280 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
284 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
285 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
286 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
287 |
|
4378 | 288 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
289 |
||
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 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
292 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
293 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
294 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
295 |
|
4378 | 296 |
end; |
297 |
||
6999 | 298 |
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
4378 | 299 |
begin |
6999 | 300 |
DrawTextureRotated(SpritesData[Sprite].Texture, |
4378 | 301 |
SpritesData[Sprite].Width, |
302 |
SpritesData[Sprite].Height, |
|
303 |
X, Y, Dir, Angle) |
|
304 |
end; |
|
305 |
||
6999 | 306 |
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
4378 | 307 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
308 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
309 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
310 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
311 |
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
|
312 |
{$ELSE} |
4378 | 313 |
glPushMatrix; |
314 |
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
|
315 |
{$ENDIF} |
4378 | 316 |
|
317 |
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
|
318 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
319 |
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
|
320 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
321 |
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
|
322 |
{$ENDIF} |
4378 | 323 |
else |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
324 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
325 |
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
|
326 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
327 |
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
|
328 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
329 |
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
|
330 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
331 |
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
|
332 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
333 |
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
|
334 |
{$ENDIF} |
4378 | 335 |
|
336 |
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); |
|
337 |
||
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 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
340 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
341 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
342 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
343 |
|
4378 | 344 |
end; |
345 |
||
6999 | 346 |
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
4378 | 347 |
var VertexBuffer: array [0..3] of TVertex2f; |
348 |
begin |
|
5565 | 349 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4378 | 350 |
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then |
351 |
exit; |
|
352 |
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then |
|
353 |
exit; |
|
354 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
355 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
356 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
357 |
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
|
358 |
{$ELSE} |
4378 | 359 |
glPushMatrix; |
360 |
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
|
361 |
{$ENDIF} |
4378 | 362 |
|
363 |
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
|
364 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
365 |
hw:= - hw; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
366 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
367 |
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
|
368 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
369 |
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
|
370 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
371 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
372 |
else |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
373 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
374 |
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
|
375 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
376 |
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
|
377 |
{$ENDIF} |
4378 | 378 |
|
6999 | 379 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
4378 | 380 |
|
381 |
VertexBuffer[0].X:= -hw; |
|
382 |
VertexBuffer[0].Y:= -hh; |
|
383 |
VertexBuffer[1].X:= hw; |
|
384 |
VertexBuffer[1].Y:= -hh; |
|
385 |
VertexBuffer[2].X:= hw; |
|
386 |
VertexBuffer[2].Y:= hh; |
|
387 |
VertexBuffer[3].X:= -hw; |
|
388 |
VertexBuffer[3].Y:= hh; |
|
389 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
390 |
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
|
391 |
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
|
392 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
393 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
394 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
395 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
396 |
|
4378 | 397 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
398 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
399 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
400 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
401 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
402 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
403 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
404 |
|
4378 | 405 |
end; |
406 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
407 |
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
4378 | 408 |
var row, col, numFramesFirstCol: LongInt; |
409 |
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
|
410 |
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
|
411 |
exit; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
412 |
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
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
417 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
r.h:= SpritesData[Sprite].Height; |
6999 | 425 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 426 |
end; |
427 |
||
428 |
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
|
429 |
var r: TSDL_Rect; |
|
430 |
begin |
|
431 |
r.x:= 0; |
|
432 |
r.y:= 0; |
|
433 |
r.w:= SpritesData[Sprite].Width; |
|
434 |
r.h:= SpritesData[Sprite].Height; |
|
435 |
||
436 |
if (X < LeftX) then |
|
437 |
r.x:= LeftX - X; |
|
438 |
if (Y < TopY) then |
|
439 |
r.y:= TopY - Y; |
|
440 |
||
441 |
if (Y + SpritesData[Sprite].Height > BottomY) then |
|
442 |
r.h:= BottomY - Y + 1; |
|
443 |
if (X + SpritesData[Sprite].Width > RightX) then |
|
444 |
r.w:= RightX - X + 1; |
|
445 |
||
10015 | 446 |
if (r.h < r.y) or (r.w < r.x) then |
9792
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
447 |
exit; |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
448 |
|
4378 | 449 |
dec(r.h, r.y); |
450 |
dec(r.w, r.x); |
|
451 |
||
6999 | 452 |
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
4378 | 453 |
end; |
454 |
||
6999 | 455 |
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); |
4378 | 456 |
var scale: GLfloat; |
457 |
begin |
|
458 |
if (Source^.w + 20) > cScreenWidth then |
|
459 |
scale:= cScreenWidth / (Source^.w + 20) |
|
460 |
else |
|
461 |
scale:= 1.0; |
|
462 |
DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale) |
|
463 |
end; |
|
464 |
||
9557 | 465 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
466 |
begin |
|
467 |
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
|
468 |
end; |
|
469 |
||
4378 | 470 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
8626 | 471 |
var VertexBuffer: array [0..1] of TVertex2f; |
4378 | 472 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
473 |
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
|
474 |
{$IFNDEF GL2} |
4378 | 475 |
glDisable(GL_TEXTURE_2D); |
476 |
||
477 |
glPushMatrix; |
|
478 |
glTranslatef(WorldDx, WorldDy, 0); |
|
479 |
glLineWidth(Width); |
|
480 |
||
481 |
Tint(r, g, b, a); |
|
482 |
VertexBuffer[0].X:= X0; |
|
483 |
VertexBuffer[0].Y:= Y0; |
|
484 |
VertexBuffer[1].X:= X1; |
|
485 |
VertexBuffer[1].Y:= Y1; |
|
486 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
487 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 488 |
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
|
489 |
untint; |
10015 | 490 |
|
4378 | 491 |
glPopMatrix; |
8330 | 492 |
|
4378 | 493 |
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
|
494 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
495 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
496 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
497 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
498 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
499 |
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
|
500 |
glLineWidth(Width); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
501 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
502 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
503 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
504 |
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
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
510 |
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
|
511 |
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
|
512 |
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
|
513 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
514 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
515 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
516 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
517 |
{$ENDIF} |
4378 | 518 |
glDisable(GL_LINE_SMOOTH); |
519 |
end; |
|
520 |
||
521 |
procedure DrawFillRect(r: TSDL_Rect); |
|
522 |
var VertexBuffer: array [0..3] of TVertex2f; |
|
523 |
begin |
|
5565 | 524 |
// 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
|
525 |
|
4378 | 526 |
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then |
527 |
exit; |
|
528 |
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then |
|
529 |
exit; |
|
530 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
531 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
532 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
533 |
{$ELSE} |
4378 | 534 |
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
|
535 |
{$ENDIF} |
4378 | 536 |
|
537 |
Tint($00, $00, $00, $80); |
|
538 |
||
539 |
VertexBuffer[0].X:= r.x; |
|
540 |
VertexBuffer[0].Y:= r.y; |
|
541 |
VertexBuffer[1].X:= r.x + r.w; |
|
542 |
VertexBuffer[1].Y:= r.y; |
|
543 |
VertexBuffer[2].X:= r.x + r.w; |
|
544 |
VertexBuffer[2].Y:= r.y + r.h; |
|
545 |
VertexBuffer[3].X:= r.x; |
|
546 |
VertexBuffer[3].Y:= r.y + r.h; |
|
547 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
548 |
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); |
4378 | 549 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
550 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
551 |
untint; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
552 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
553 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
554 |
{$ELSE} |
4378 | 555 |
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
|
556 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
557 |
|
4378 | 558 |
end; |
559 |
||
8330 | 560 |
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
|
561 |
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
|
562 |
Tint(r, g, b, a); |
10015 | 563 |
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
|
564 |
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
|
565 |
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
|
566 |
|
8330 | 567 |
procedure DrawCircle(X, Y, Radius, Width: LongInt); |
4378 | 568 |
var |
569 |
i: LongInt; |
|
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
570 |
CircleVertex: array [0..59] of TVertex2f; |
4378 | 571 |
begin |
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
572 |
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
|
573 |
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
|
574 |
CircleVertex[i].Y := Y + Radius*sin(i*pi/30); |
4378 | 575 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
576 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
577 |
{$IFNDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
578 |
|
4378 | 579 |
glDisable(GL_TEXTURE_2D); |
580 |
glEnable(GL_LINE_SMOOTH); |
|
581 |
glPushMatrix; |
|
582 |
glLineWidth(Width); |
|
583 |
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
|
584 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
4378 | 585 |
glPopMatrix; |
586 |
glEnable(GL_TEXTURE_2D); |
|
587 |
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
|
588 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
589 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
590 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
591 |
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
|
592 |
hglPushMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
593 |
glLineWidth(Width); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
597 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
598 |
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
|
599 |
{$ENDIF} |
4378 | 600 |
end; |
601 |
||
602 |
||
4385 | 603 |
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
604 |
const VertexBuffer: array [0..3] of TVertex2f = ( |
|
7069 | 605 |
(X: -16; Y: -16), |
606 |
(X: 16; Y: -16), |
|
607 |
(X: 16; Y: 16), |
|
608 |
(X: -16; Y: 16)); |
|
4385 | 609 |
var l, r, t, b: real; |
610 |
TextureBuffer: array [0..3] of TVertex2f; |
|
611 |
begin |
|
5565 | 612 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
4385 | 613 |
if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then |
614 |
exit; |
|
615 |
if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then |
|
616 |
exit; |
|
617 |
||
618 |
t:= Pos * 32 / HHTexture^.h; |
|
619 |
b:= (Pos + 1) * 32 / HHTexture^.h; |
|
620 |
||
621 |
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
|
622 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
623 |
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
|
624 |
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
|
625 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
626 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
627 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
628 |
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
|
629 |
r:= (Step + 1) * 32 / HHTexture^.w |
4385 | 630 |
end; |
631 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
632 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
633 |
hglPushMatrix(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
634 |
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
|
635 |
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
|
636 |
{$ELSE} |
4385 | 637 |
glPushMatrix(); |
638 |
glTranslatef(X, Y, 0); |
|
639 |
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
|
640 |
{$ENDIF} |
4385 | 641 |
|
642 |
glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
643 |
||
644 |
TextureBuffer[0].X:= l; |
|
645 |
TextureBuffer[0].Y:= t; |
|
646 |
TextureBuffer[1].X:= r; |
|
647 |
TextureBuffer[1].Y:= t; |
|
648 |
TextureBuffer[2].X:= r; |
|
649 |
TextureBuffer[2].Y:= b; |
|
650 |
TextureBuffer[3].X:= l; |
|
651 |
TextureBuffer[3].Y:= b; |
|
652 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
653 |
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
|
654 |
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
|
655 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
656 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
657 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
658 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
659 |
|
4385 | 660 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
661 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
662 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
663 |
hglPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
664 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
665 |
glPopMatrix; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
666 |
{$ENDIF} |
4385 | 667 |
end; |
668 |
||
6688 | 669 |
procedure DrawScreenWidget(widget: POnScreenWidget); |
6992 | 670 |
{$IFDEF USE_TOUCH_INTERFACE} |
6688 | 671 |
var alpha: byte = $FF; |
672 |
begin |
|
673 |
with widget^ do |
|
674 |
begin |
|
675 |
if (fadeAnimStart <> 0) then |
|
676 |
begin |
|
677 |
if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then |
|
678 |
fadeAnimStart:= 0 |
|
679 |
else |
|
8330 | 680 |
if show then |
6688 | 681 |
alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) |
8330 | 682 |
else |
6688 | 683 |
alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); |
684 |
end; |
|
685 |
||
686 |
with moveAnim do |
|
687 |
if animate then |
|
688 |
if RealTicks > (startTime + MOVE_ANIM_TIME) then |
|
689 |
begin |
|
690 |
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
|
691 |
animate:= false; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
692 |
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
|
693 |
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
|
694 |
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
|
695 |
active.y:= active.y + (target.y - source.y); |
6688 | 696 |
end |
697 |
else |
|
698 |
begin |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
699 |
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
|
700 |
frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); |
6688 | 701 |
end; |
702 |
||
703 |
if show or (fadeAnimStart <> 0) then |
|
704 |
begin |
|
705 |
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
|
706 |
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
|
707 |
untint; |
6688 | 708 |
end; |
709 |
end; |
|
6992 | 710 |
{$ELSE} |
711 |
begin |
|
712 |
widget:= widget; // avoid hint |
|
6689 | 713 |
{$ENDIF} |
6688 | 714 |
end; |
4385 | 715 |
|
4378 | 716 |
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
|
717 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
718 |
nc, tw: Longword; |
10015 | 719 |
{$IFDEF GL2} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
720 |
scale:Real = 1.0/255.0; |
10015 | 721 |
{$ENDIF} |
4378 | 722 |
begin |
9557 | 723 |
nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; |
5559 | 724 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
725 |
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
|
726 |
exit; |
5559 | 727 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
728 |
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
|
729 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
end; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
737 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
738 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
739 |
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
|
740 |
//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
|
741 |
{$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
|
742 |
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
|
743 |
{$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
|
744 |
lastTint:= nc; |
4378 | 745 |
end; |
746 |
||
747 |
procedure Tint(c: Longword); inline; |
|
748 |
begin |
|
9557 | 749 |
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
|
750 |
Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) |
4378 | 751 |
end; |
752 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
753 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
754 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
755 |
Tint($FF, $FF, $FF, $FF) |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
756 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
757 |
|
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
758 |
procedure setTintAdd(f: boolean); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
759 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
760 |
if f then |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
761 |
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
|
762 |
else |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
763 |
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
|
764 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
765 |
|
4378 | 766 |
end. |