DEADSOFTWARE

render: separate gfx logic and drawing
[d2df-sdl.git] / src / game / opengl / r_gfx.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_gfx;
18 interface
20 procedure r_GFX_Draw;
22 implementation
24 uses
25 {$INCLUDE ../nogl/noGLuses.inc}
26 SysUtils, Classes, Math,
27 utils,
28 e_graphics,
29 g_game,
30 g_gfx
31 ;
33 procedure r_GFX_Draw;
34 var
35 a, len, fx, fy: Integer;
36 begin
37 if not gpart_dbg_enabled then exit;
39 if (Particles <> nil) then
40 begin
41 glDisable(GL_TEXTURE_2D);
42 if (g_dbg_scale < 0.6) then glPointSize(1)
43 else if (g_dbg_scale > 1.3) then glPointSize(g_dbg_scale+1)
44 else glPointSize(2);
45 glDisable(GL_POINT_SMOOTH);
47 glEnable(GL_BLEND);
48 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
50 glBegin(GL_POINTS);
52 len := High(Particles);
53 for a := 0 to len do
54 begin
55 with Particles[a] do
56 begin
57 if not alive then continue;
58 if (x >= sX) and (y >= sY) and (x <= sX+sWidth) and (sY <= sY+sHeight) then
59 begin
60 fx := nlerp(oldx, x, gLerpFactor);
61 fy := nlerp(oldy, y, gLerpFactor);
62 glColor4ub(red, green, blue, alpha);
63 glVertex2f(fx+0.37, fy+0.37);
64 end;
65 end;
66 end;
68 glEnd();
70 glDisable(GL_BLEND);
71 end;
73 if (OnceAnims <> nil) then
74 begin
75 len := High(OnceAnims);
76 for a := 0 to len do
77 begin
78 if (OnceAnims[a].Animation <> nil) then
79 begin
80 with OnceAnims[a] do
81 begin
82 fx := nlerp(oldx, x, gLerpFactor);
83 fy := nlerp(oldy, y, gLerpFactor);
84 Animation.Draw(x, y, TMirrorType.None);
85 end;
86 end;
87 end;
88 end;
89 end;
91 end.