1 (* Copyright (C) Doom 2D: Forever Developers
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.
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.
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/>.
15 {$INCLUDE ../../shared/a_modes.inc}
20 uses MAPDEF
; // TDFColor
22 procedure r_Map_DrawBack (dx
, dy
: Integer);
23 procedure r_Map_DrawPanels (PanelType
: Word; hasAmbient
: Boolean; constref ambColor
: TDFColor
); // unaccelerated
24 procedure r_Map_CollectDrawPanels (x0
, y0
, wdt
, hgt
: Integer);
25 procedure r_Map_DrawPanelShadowVolumes (lightX
: Integer; lightY
: Integer; radius
: Integer);
26 procedure r_Map_DrawFlags
;
31 {$INCLUDE ../nogl/noGLuses.inc}
32 SysUtils
, Classes
, Math
,
34 g_base
, g_basic
, g_game
, g_options
,
39 procedure dplClear ();
41 if (gDrawPanelList
= nil) then gDrawPanelList
:= TBinHeapPanelDraw
.Create() else gDrawPanelList
.clear();
45 procedure r_Map_DrawPanels (PanelType
: Word; hasAmbient
: Boolean; constref ambColor
: TDFColor
);
47 procedure DrawPanels (constref panels
: TPanelArray
; drawDoors
: Boolean=False);
51 if (panels
<> nil) then
53 // alas, no visible set
54 for idx
:= 0 to High(panels
) do
56 if not (drawDoors
xor panels
[idx
].Door
) then
57 r_Panel_Draw(panels
[idx
], hasAmbient
, ambColor
);
64 PANEL_WALL
: DrawPanels(gWalls
);
65 PANEL_CLOSEDOOR
: DrawPanels(gWalls
, True);
66 PANEL_BACK
: DrawPanels(gRenderBackgrounds
);
67 PANEL_FORE
: DrawPanels(gRenderForegrounds
);
68 PANEL_WATER
: DrawPanels(gWater
);
69 PANEL_ACID1
: DrawPanels(gAcid1
);
70 PANEL_ACID2
: DrawPanels(gAcid2
);
71 PANEL_STEP
: DrawPanels(gSteps
);
76 procedure r_Map_CollectDrawPanels (x0
, y0
, wdt
, hgt
: Integer);
82 it
:= mapGrid
.forEachInAABB(x0
, y0
, wdt
, hgt
, GridDrawableMask
);
83 for mwit
in it
do if (((mwit
^.tag
and GridTagDoor
) <> 0) = mwit
^.Door
) then gDrawPanelList
.insert(mwit
^);
85 // list will be rendered in `g_game.DrawPlayer()`
88 procedure r_Map_DrawPanelShadowVolumes (lightX
: Integer; lightY
: Integer; radius
: Integer);
93 it
:= mapGrid
.forEachInAABB(lightX
-radius
, lightY
-radius
, radius
*2, radius
*2, (GridTagWall
or GridTagDoor
));
94 for mwit
in it
do r_Panel_DrawShadowVolume(mwit
^, lightX
, lightY
, radius
);
98 procedure r_Map_DrawBack(dx
, dy
: Integer);
100 if gDrawBackGround
and (BackID
<> DWORD(-1)) then
101 e_DrawSize(BackID
, dx
, dy
, 0, False, False, gBackSize
.X
, gBackSize
.Y
)
103 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
106 procedure r_Map_DrawFlags();
112 if gGameSettings
.GameMode
<> GM_CTF
then
115 for i
:= FLAG_RED
to FLAG_BLUE
do
117 if State
<> FLAG_STATE_CAPTURED
then
119 if State
= FLAG_STATE_NONE
then
122 Obj
.lerp(gLerpFactor
, tx
, ty
);
124 if Direction
= TDirection
.D_LEFT
then
126 Mirror
:= TMirrorType
.Horizontal
;
131 Mirror
:= TMirrorType
.None
;
135 Animation
.Draw(tx
+ dx
, ty
+ 1, Mirror
);
137 if g_debug_Frames
then
139 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
141 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
142 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,