DEADSOFTWARE

016aed3c0ac210c20ed5b23b1606aa7bdd2d5205
[d2df-sdl.git] / src / game / renders / opengl / r_map.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../../../shared/a_modes.inc}
16 unit r_map;
18 interface
20 procedure r_Map_Initialize;
21 procedure r_Map_Finalize;
23 procedure r_Map_Load;
24 procedure r_Map_Free;
26 procedure r_Map_LoadTextures;
27 procedure r_Map_FreeTextures;
29 procedure r_Map_Update;
31 procedure r_Map_Draw (x, y, w, h, camx, camy: Integer);
33 implementation
35 uses
36 {$IFDEF USE_GLES1}
37 GLES11,
38 {$ELSE}
39 GL, GLEXT,
40 {$ENDIF}
41 e_log,
42 binheap, MAPDEF, utils,
43 g_options, g_textures, g_basic, g_base, g_phys,
44 g_game, g_map, g_panel, g_items, g_monsters, g_playermodel, g_player,
45 {$IFDEF ENABLE_CORPSES}
46 g_corpses,
47 {$ENDIF}
48 r_textures, r_draw
49 ;
51 const
52 MTABLE: array [0..MONSTER_MAN] of record
53 w, h: Integer;
54 end = (
55 (w: 64; h: 64), // NONE
56 (w: 64; h: 64), // DEMON
57 (w: 64; h: 64), // IMP
58 (w: 64; h: 64), // ZOMBY
59 (w: 64; h: 64), // SERG
60 (w: 128; h: 128), // CYBER
61 (w: 64; h: 64), // CGUN
62 (w: 128; h: 128), // BARON
63 (w: 128; h: 128), // KNIGHT
64 (w: 128; h: 128), // CACO
65 (w: 64; h: 64), // SOUL (DIE is 128x128, see load code)
66 (w: 128; h: 128), // PAIN
67 (w: 256; h: 128), // SPIDER
68 (w: 128; h: 64), // BSP
69 (w: 128; h: 128), // MANCUB
70 (w: 128; h: 128), // SKEL
71 (w: 128; h: 128), // VILE
72 (w: 32; h: 32), // FISH
73 (w: 64; h: 64), // BARREL
74 (w: 128; h: 128), // ROBO
75 (w: 64; h: 64) // MAN
76 );
77 VILEFIRE_DX = 32;
78 VILEFIRE_DY = 128;
80 type
81 TBinHeapPanelDrawCmp = class
82 public
83 class function less (const a, b: TPanel): Boolean; inline;
84 end;
86 TBinHeapPanelDraw = specialize TBinaryHeapBase<TPanel, TBinHeapPanelDrawCmp>;
88 TMonsterAnims = array [0..ANIM_LAST, TDirection] of TGLMultiTexture;
90 var
91 SkyTexture: TGLTexture;
92 RenTextures: array of record
93 spec: LongInt;
94 tex: TGLMultiTexture;
95 end;
96 Items: array [0..ITEM_MAX] of record
97 tex: TGLMultiTexture;
98 anim: TAnimState;
99 end;
100 MonTextures: array [0..MONSTER_MAN] of TMonsterAnims;
101 VileFire: TGLMultiTexture;
102 Models: array of record
103 anim: array [TDirection, 0..A_LAST] of record
104 base, mask: TGLMultiTexture;
105 end;
106 (*
107 {$IFDEF ENABLE_GIBS}
108 gibs: array of record
109 base, mask: TGLTexture;
110 rect: TRectWH;
111 end;
112 {$ENDIF}
113 *)
114 end;
116 plist: TBinHeapPanelDraw = nil;
118 class function TBinHeapPanelDrawCmp.less (const a, b: TPanel): Boolean; inline;
119 begin
120 if a.tag < b.tag then begin result := true; exit; end;
121 if a.tag > b.tag then begin result := false; exit; end;
122 result := a.arrIdx < b.arrIdx;
123 end;
125 procedure r_Map_Initialize;
126 begin
127 plist := TBinHeapPanelDraw.Create();
128 end;
130 procedure r_Map_Finalize;
131 begin
132 plist.Free
133 end;
135 procedure r_Map_LoadModel (i: Integer);
136 var prefix: AnsiString; a: Integer; d: TDirection; m: ^TPlayerModelInfo;
137 begin
138 m := @PlayerModelsArray[i];
139 prefix := m.FileName + ':TEXTURES/';
140 for d := TDirection.D_LEFT to TDirection.D_RIGHT do
141 begin
142 for a := A_STAND to A_LAST do
143 begin
144 Models[i].anim[d, a].base := nil;
145 Models[i].anim[d, a].mask := nil;
146 if m.anim[d, a].resource <> '' then
147 Models[i].anim[d, a].base := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].resource, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
148 if m.anim[d, a].mask <> '' then
149 Models[i].anim[d, a].mask := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].mask, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
150 end
151 end;
152 (*
153 {$IFDEF ENABLE_GIBS}
154 Models[i].gibs := nil;
155 if m.GibsCount > 0 then
156 begin
157 SetLength(Models[i].gibs, m.GibsCount);
158 end;
159 {$ENDIF}
160 *)
161 end;
164 procedure r_Map_Load;
165 var i, j: Integer; d: TDirection;
167 procedure LoadItem (i: Integer; const name: AnsiString; w, h, delay, count: Integer; backanim: Boolean);
168 begin
169 ASSERT(i >= 0);
170 ASSERT(i <= ITEM_MAX);
171 Items[i].tex := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/' + name, w, h, count, backanim, false);
172 if backanim then count := count * 2 - 2;
173 Items[i].anim := TAnimState.Create(True, delay, count);
174 ASSERT(Items[i].tex <> NIL);
175 end;
177 procedure LoadMonster (m, a: Integer; d: TDirection);
178 const
179 dir: array [TDirection] of AnsiString = ('_L', '');
180 var
181 w, h, count: Integer;
182 begin
183 count := MONSTER_ANIMTABLE[m].AnimCount[a];
184 if count > 0 then
185 begin
186 w := MTABLE[m].w;
187 h := MTABLE[m].h;
188 if (m = MONSTER_SOUL) and (a = ANIM_DIE) then
189 begin
190 // special case
191 w := 128;
192 h := 128;
193 end;
194 MonTextures[m, a, d] := r_Textures_LoadMultiFromFileAndInfo(
195 GameWAD + ':MTEXTURES/' + MONSTERTABLE[m].name + '_' + ANIMTABLE[a].name + dir[d],
196 w,
197 h,
198 count,
199 False,
200 False
202 end
203 else
204 MonTextures[m, a, d] := nil
205 end;
207 begin
208 // --------- items --------- //
209 // i name w h d n backanim
210 LoadItem(ITEM_NONE, 'NOTEXTURE', 16, 16, 0, 1, False);
211 LoadItem(ITEM_MEDKIT_SMALL, 'MED1', 16, 16, 0, 1, False);
212 LoadItem(ITEM_MEDKIT_LARGE, 'MED2', 32, 32, 0, 1, False);
213 LoadItem(ITEM_MEDKIT_BLACK, 'BMED', 32, 32, 0, 1, False);
214 LoadItem(ITEM_ARMOR_GREEN, 'ARMORGREEN', 32, 16, 20, 3, True);
215 LoadItem(ITEM_ARMOR_BLUE, 'ARMORBLUE', 32, 16, 20, 3, True);
216 LoadItem(ITEM_SPHERE_BLUE, 'SBLUE', 32, 32, 15, 4, True);
217 LoadItem(ITEM_SPHERE_WHITE, 'SWHITE', 32, 32, 20, 4, True);
218 LoadItem(ITEM_SUIT, 'SUIT', 32, 64, 0, 1, False);
219 LoadItem(ITEM_OXYGEN, 'OXYGEN', 16, 32, 0, 1, False);
220 LoadItem(ITEM_INVUL, 'INVUL', 32, 32, 20, 4, True);
221 LoadItem(ITEM_WEAPON_SAW, 'SAW', 64, 32, 0, 1, False);
222 LoadItem(ITEM_WEAPON_SHOTGUN1, 'SHOTGUN1', 64, 16, 0, 1, False);
223 LoadItem(ITEM_WEAPON_SHOTGUN2, 'SHOTGUN2', 64, 16, 0, 1, False);
224 LoadItem(ITEM_WEAPON_CHAINGUN, 'MGUN', 64, 16, 0, 1, False);
225 LoadItem(ITEM_WEAPON_ROCKETLAUNCHER, 'RLAUNCHER', 64, 16, 0, 1, False);
226 LoadItem(ITEM_WEAPON_PLASMA, 'PGUN', 64, 16, 0, 1, False);
227 LoadItem(ITEM_WEAPON_BFG, 'BFG', 64, 64, 0, 1, False);
228 LoadItem(ITEM_WEAPON_SUPERPULEMET, 'SPULEMET', 64, 16, 0, 1, False);
229 LoadItem(ITEM_AMMO_BULLETS, 'CLIP', 16, 16, 0, 1, False);
230 LoadItem(ITEM_AMMO_BULLETS_BOX, 'AMMO', 32, 16, 0, 1, False);
231 LoadItem(ITEM_AMMO_SHELLS, 'SHELL1', 16, 8, 0, 1, False);
232 LoadItem(ITEM_AMMO_SHELLS_BOX, 'SHELL2', 32, 16, 0, 1, False);
233 LoadItem(ITEM_AMMO_ROCKET, 'ROCKET', 16, 32, 0, 1, False);
234 LoadItem(ITEM_AMMO_ROCKET_BOX, 'ROCKETS', 64, 32, 0, 1, False);
235 LoadItem(ITEM_AMMO_CELL, 'CELL', 16, 16, 0, 1, False);
236 LoadItem(ITEM_AMMO_CELL_BIG, 'CELL2', 32, 32, 0, 1, False);
237 LoadItem(ITEM_AMMO_BACKPACK, 'BPACK', 32, 32, 0, 1, False);
238 LoadItem(ITEM_KEY_RED, 'KEYR', 16, 16, 0, 1, False);
239 LoadItem(ITEM_KEY_GREEN, 'KEYG', 16, 16, 0, 1, False);
240 LoadItem(ITEM_KEY_BLUE, 'KEYB', 16, 16, 0, 1, False);
241 LoadItem(ITEM_WEAPON_KASTET, 'KASTET', 64, 32, 0, 1, False);
242 LoadItem(ITEM_WEAPON_PISTOL, 'PISTOL', 64, 16, 0, 1, False);
243 LoadItem(ITEM_BOTTLE, 'BOTTLE', 16, 32, 20, 4, True);
244 LoadItem(ITEM_HELMET, 'HELMET', 16, 16, 20, 4, True);
245 LoadItem(ITEM_JETPACK, 'JETPACK', 32, 32, 15, 3, True);
246 LoadItem(ITEM_INVIS, 'INVIS', 32, 32, 20, 4, True);
247 LoadItem(ITEM_WEAPON_FLAMETHROWER, 'FLAMETHROWER', 64, 32, 0, 1, False);
248 LoadItem(ITEM_AMMO_FUELCAN, 'FUELCAN', 16, 32, 0, 1, False);
249 // fill with NOTEXURE forgotten item
250 for i := ITEM_AMMO_FUELCAN + 1 to ITEM_MAX do
251 LoadItem(i,'NOTEXTURE', 16, 16, 0, 1, False);
252 // --------- monsters --------- //
253 for i := MONSTER_DEMON to MONSTER_MAN do
254 for j := 0 to ANIM_LAST do
255 for d := TDirection.D_LEFT to TDirection.D_RIGHT do
256 LoadMonster(i, j, d);
257 VileFire := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/FIRE', 64, 128, 8, False, False);
258 // --------- player models --------- //
259 if PlayerModelsArray <> nil then
260 begin
261 SetLength(Models, Length(PlayerModelsArray));
262 for i := 0 to High(PlayerModelsArray) do
263 r_Map_LoadModel(i);
264 end;
265 end;
267 procedure r_Map_Free;
268 var i, j: Integer; d: TDirection;
269 begin
270 for i := MONSTER_DEMON to MONSTER_MAN do
271 begin
272 for j := 0 to ANIM_LAST do
273 begin
274 for d := TDirection.D_LEFT to TDirection.D_RIGHT do
275 begin
276 if MonTextures[i, j, d] <> nil then
277 MonTextures[i, j, d].Free;
278 MonTextures[i, j, d] := nil;
279 end;
280 end;
281 end;
282 for i := 0 to ITEM_MAX do
283 begin
284 if Items[i].tex <> nil then
285 begin
286 Items[i].tex.Free;
287 Items[i].tex := nil;
288 end;
289 Items[i].anim.Invalidate;
290 end;
291 end;
293 procedure r_Map_LoadTextures;
294 var i, n: Integer;
295 begin
296 if Textures <> nil then
297 begin
298 n := Length(Textures);
299 SetLength(RenTextures, n);
300 for i := 0 to n - 1 do
301 begin
302 RenTextures[i].tex := nil;
303 case Textures[i].TextureName of
304 TEXTURE_NAME_WATER: RenTextures[i].spec := TEXTURE_SPECIAL_WATER;
305 TEXTURE_NAME_ACID1: RenTextures[i].spec := TEXTURE_SPECIAL_ACID1;
306 TEXTURE_NAME_ACID2: RenTextures[i].spec := TEXTURE_SPECIAL_ACID2;
307 else
308 RenTextures[i].spec := 0;
309 RenTextures[i].tex := r_Textures_LoadMultiFromFile(Textures[i].FullName);
310 if RenTextures[i].tex = nil then
311 e_LogWritefln('r_Map_LoadTextures: failed to load texture: %s', [Textures[i].FullName]);
312 end;
313 end;
314 end;
315 if gMapInfo.SkyFullName <> '' then
316 SkyTexture := r_Textures_LoadFromFile(gMapInfo.SkyFullName);
317 plist.Clear;
318 end;
320 procedure r_Map_FreeTextures;
321 var i: Integer;
322 begin
323 plist.Clear;
324 if SkyTexture <> nil then
325 SkyTexture.Free;
326 SkyTexture := nil;
327 if RenTextures <> nil then
328 for i := 0 to High(RenTextures) do
329 if RenTextures[i].tex <> nil then
330 RenTextures[i].tex.Free;
331 RenTextures := nil;
332 end;
334 procedure r_Map_Update;
335 var i: Integer;
336 begin
337 for i := 0 to ITEM_MAX do
338 Items[i].anim.Update;
339 end;
341 procedure r_Map_DrawPanel (p: TPanel);
342 var Texture: Integer; t: TGLMultiTexture;
343 begin
344 ASSERT(p <> nil);
345 if p.FCurTexture >= 0 then
346 begin
347 Texture := p.TextureIDs[p.FCurTexture].Texture;
348 t := RenTextures[Texture].tex;
350 if (RenTextures[Texture].spec = 0) or (t <> nil) then
351 begin
352 // TODO set alpha and blending type
353 if t = nil then
354 r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false)
355 else if p.TextureIDs[p.FCurTexture].AnTex.IsValid() then
356 r_Draw_MultiTextureRepeat(t, p.TextureIDs[p.FCurTexture].AnTex, p.x, p.y, p.width, p.height, false)
357 else
358 r_Draw_TextureRepeat(t.GetTexture(0), p.x, p.y, p.width, p.height, false)
359 end;
361 if t = nil then
362 begin
363 case RenTextures[Texture].spec of
364 TEXTURE_SPECIAL_WATER: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 0, 0, 255, 255);
365 TEXTURE_SPECIAL_ACID1: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 0, 230, 0, 255);
366 TEXTURE_SPECIAL_ACID2: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 230, 0, 0, 255);
367 end
368 end
369 end
370 end;
372 procedure r_Map_DrawPanelType (panelTyp: DWORD);
373 var tagMask, i: Integer; p: TPanel;
374 begin
375 i := 0;
376 tagMask := PanelTypeToTag(panelTyp);
377 while plist.count > 0 do
378 begin
379 p := TPanel(plist.Front());
380 if (p.tag and tagMask) = 0 then
381 break;
382 r_Map_DrawPanel(p);
383 Inc(i);
384 plist.PopFront
385 end;
386 end;
388 procedure r_Map_DrawItems (x, y, w, h: Integer; drop: Boolean);
389 var i, fX, fY: Integer; it: PItem; t: TGLMultiTexture;
390 begin
391 if ggItems <> nil then
392 begin
393 for i := 0 to High(ggItems) do
394 begin
395 it := @ggItems[i];
396 if it.used and it.alive and (it.dropped = drop) and (it.ItemType <> ITEM_NONE) then
397 begin
398 t := Items[it.ItemType].tex;
399 if g_Collide(it.obj.x, it.obj.y, t.width, t.height, x, y, w, h) then
400 begin
401 it.obj.Lerp(gLerpFactor, fX, fY);
402 r_Draw_MultiTextureRepeat(t, Items[it.ItemType].anim, fX, fY, t.width, t.height, false);
403 // if g_debug_frames then // TODO draw collision frame
404 end;
405 end;
406 end;
407 end;
408 end;
410 function r_Map_GetMonsterTexture (m, a: Integer; d: TDirection; out t: TGLMultiTexture; out dx, dy: Integer; out flip: Boolean): Boolean;
411 // var c: Integer;
412 begin
413 t := nil; dx := 0; dy := 0; flip := false;
414 result := MonTextures[m, a, d] <> nil;
415 if result = false then
416 begin
417 flip := true;
418 if d = TDirection.D_RIGHT then d := TDirection.D_LEFT else d := TDirection.D_RIGHT;
419 result := MonTextures[m, a, d] <> nil;
420 end;
421 if result = true then
422 begin
423 t := MonTextures[m, a, d];
424 if d = TDirection.D_LEFT then
425 begin
426 dx := MONSTER_ANIMTABLE[m].AnimDeltaLeft[a].X;
427 dy := MONSTER_ANIMTABLE[m].AnimDeltaLeft[a].Y;
428 end
429 else
430 begin
431 dx := MONSTER_ANIMTABLE[m].AnimDeltaRight[a].X;
432 dy := MONSTER_ANIMTABLE[m].AnimDeltaRight[a].Y;
433 end;
434 if flip then
435 begin
436 // c := (MONSTERTABLE[MonsterType].Rect.X - dx) + MONSTERTABLE[MonsterType].Rect.Width;
437 // dx := MTABLE[m].width - c - MONSTERTABLE[MonsterType].Rect.X;
438 dx := -dx;
439 end;
440 end;
441 end;
443 procedure r_Map_DrawMonsterAttack (constref mon: TMonster);
444 var o: TObj;
445 begin
446 if VileFire <> nil then
447 if (mon.MonsterType = MONSTER_VILE) and (mon.MonsterState = MONSTATE_SHOOT) then
448 if mon.VileFireAnim.IsValid() and GetPos(mon.MonsterTargetUID, @o) then
449 r_Draw_MultiTextureRepeat(VileFire, mon.VileFireAnim, o.x + o.rect.x + (o.rect.width div 2) - VILEFIRE_DX, o.y + o.rect.y + o.rect.height - VILEFIRE_DY, VileFire.width, VileFire.height, False);
450 end;
452 procedure r_Map_DrawMonster (constref mon: TMonster);
453 var m, a, fX, fY, dx, dy: Integer; d: TDirection; flip: Boolean; t: TGLMultiTexture;
454 begin
455 m := mon.MonsterType;
456 a := mon.MonsterAnim;
457 d := mon.GameDirection;
459 mon.obj.Lerp(gLerpFactor, fX, fY);
461 if r_Map_GetMonsterTexture(m, a, d, t, dx, dy, flip) then
462 r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, d], fX + dx, fY + dy, t.width, t.height, flip);
465 if g_debug_frames
466 // TODO draw frame
468 end;
470 procedure r_Map_DrawMonsters (x, y, w, h: Integer);
471 var i: Integer; m: TMonster;
472 begin
473 if gMonsters <> nil then
474 begin
475 for i := 0 to High(gMonsters) do
476 begin
477 m := gMonsters[i];
478 if m <> nil then
479 begin
480 r_Map_DrawMonsterAttack(m);
481 // TODO select from grid
482 if g_Collide(m.obj.x + m.obj.rect.x, m.obj.y + m.obj.rect.y, m.obj.rect.width, m.obj.rect.height, x, y, w, h) then
483 r_Map_DrawMonster(m);
484 end;
485 end;
486 end;
487 end;
489 function r_Map_GetPlayerModelTex (i: Integer; var a: Integer; var d: TDirection; out flip: Boolean): Boolean;
490 begin
491 flip := false;
492 result := Models[i].anim[d, a].base <> nil;
493 if result = false then
494 begin
495 flip := true;
496 if d = TDirection.D_LEFT then d := TDirection.D_RIGHT else d := TDirection.D_LEFT;
497 result := Models[i].anim[d, a].base <> nil;
498 end;
499 end;
501 procedure r_Map_DrawPlayerModel (pm: TPlayerModel; x, y: Integer);
502 var a: Integer; d: TDirection; flip: Boolean; t: TGLMultiTexture;
503 begin
504 // TODO draw flag
505 // TODO draw weapon
506 a := pm.CurrentAnimation;
507 d := pm.Direction;
508 if r_Map_GetPlayerModelTex(pm.id, a, d, flip) then
509 begin
510 t := Models[pm.id].anim[d, a].base;
511 r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip);
512 // TODO colorize mask
513 t := Models[pm.id].anim[d, a].mask;
514 if t <> nil then
515 r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip);
516 end;
517 end;
519 procedure r_Map_DrawPlayer (p: TPlayer);
520 var fX, fY, fSlope: Integer;
521 begin
522 if p.alive then
523 begin
524 fX := p.obj.x; fY := p.obj.y;
525 // TODO fix lerp
526 //p.obj.Lerp(gLerpFactor, fX, fY);
527 fSlope := nlerp(p.SlopeOld, p.obj.slopeUpLeft, gLerpFactor);
528 // TODO draw punch
529 // TODO invul pentagram
530 // TODO draw it with transparency
531 r_Map_DrawPlayerModel(p.Model, fX, fY + fSlope);
532 end;
533 // TODO draw g_debug_frames
534 // TODO draw chat bubble
535 // TODO draw aim
536 end;
538 procedure r_Map_DrawPlayers (x, y, w, h: Integer);
539 var i: Integer;
540 begin
541 // TODO draw only visible
542 if gPlayers <> nil then
543 for i := 0 to High(gPlayers) do
544 if gPlayers[i] <> nil then
545 r_Map_DrawPlayer(gPlayers[i]);
546 end;
548 {$IFDEF ENABLE_CORPSES}
549 procedure r_Map_DrawCorpses (x, y, w, h: Integer);
550 var i, fX, fY: Integer; p: TCorpse;
551 begin
552 if gCorpses <> nil then
553 begin
554 for i := 0 to High(gCorpses) do
555 begin
556 p := gCorpses[i];
557 if (p <> nil) and (p.state <> CORPSE_STATE_REMOVEME) and (p.model <> nil) then
558 begin
559 p.obj.Lerp(gLerpFactor, fX, fY);
560 r_Map_DrawPlayerModel(p.model, fX, fY);
561 end;
562 end;
563 end;
564 end;
565 {$ENDIF}
567 procedure r_Map_Draw (x, y, w, h, camx, camy: Integer);
568 var iter: TPanelGrid.Iter; p: PPanel; cx, cy, xx, yy, ww, hh: Integer;
569 begin
570 cx := camx - w div 2;
571 cy := camy - h div 2;
572 xx := x + cx;
573 yy := y + cy;
574 ww := w;
575 hh := h;
577 if SkyTexture <> nil then
578 r_Draw_Texture(SkyTexture, x, y, w, h, false);
580 plist.Clear;
581 iter := mapGrid.ForEachInAABB(xx, yy, ww, hh, GridDrawableMask);
582 for p in iter do
583 if ((p^.tag and GridTagDoor) <> 0) = p^.door then
584 plist.Insert(p^);
585 iter.Release;
587 glPushMatrix;
588 glTranslatef(-cx, -cy, 0);
589 r_Map_DrawPanelType(PANEL_BACK);
590 r_Map_DrawPanelType(PANEL_STEP);
591 r_Map_DrawItems(xx, yy, ww, hh, false);
592 // TODO draw weapons
593 // TODO draw shells
594 r_Map_DrawPlayers(xx, yy, ww, hh);
595 // TODO draw gibs
596 {$IFDEF ENABLE_CORPSES}
597 r_Map_DrawCorpses(xx, yy, ww, hh);
598 {$ENDIF}
599 r_Map_DrawPanelType(PANEL_WALL);
600 r_Map_DrawMonsters(xx, yy, ww, hh);
601 r_Map_DrawItems(xx, yy, ww, hh, true);
602 r_Map_DrawPanelType(PANEL_CLOSEDOOR);
603 // TODO draw gfx
604 // TODO draw flags
605 r_Map_DrawPanelType(PANEL_ACID1);
606 r_Map_DrawPanelType(PANEL_ACID2);
607 r_Map_DrawPanelType(PANEL_WATER);
608 r_Map_DrawPanelType(PANEL_FORE);
609 glPopMatrix;
610 end;
612 end.