summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06fd971)
raw | patch | inline | side by side (parent: 06fd971)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 7 Jun 2021 17:15:24 +0000 (20:15 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 07:40:51 +0000 (10:40 +0300) |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_gfx.pas | patch | blob | history | |
src/game/opengl/r_game.pas | patch | blob | history | |
src/game/opengl/r_gfx.pas | [new file with mode: 0644] | patch | blob |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index 0a18aa66da809235d0054167040c5faf6c6b460c..adbf20556266cf7651dc6d74d098e89e863269b3 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
r_console in 'opengl/r_console.pas',
r_game in 'opengl/r_game.pas',
+ r_gfx in 'opengl/r_gfx.pas',
{$IFDEF USE_FMOD}
fmod in '../lib/FMOD/fmod.pas',
diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas
index bf8fc5aa2fd8a5e4d90b3dbd8ca47cbfb13ecfaa..3a9c79cf7b7102bce7e6e22e00dcd8e6008a491d 100644 (file)
--- a/src/game/g_gfx.pas
+++ b/src/game/g_gfx.pas
procedure g_Mark (x, y, Width, Height: Integer; t: Byte; st: Boolean=true);
procedure g_GFX_Update ();
-procedure g_GFX_Draw ();
-
var
gpart_dbg_enabled: Boolean = true;
//WARNING: only for Holmes!
function awmIsSetHolmes (x, y: Integer): Boolean; inline;
+ type (* private state *)
+ TPartType = (Blood, Spark, Bubbles, Water);
+ TPartState = (Free, Normal, Stuck, Sleeping);
+ TFloorType = (Wall, LiquidIn, LiquidOut);
+ // Wall: floorY is just before floor
+ // LiquidIn: floorY is liquid *start* (i.e. just in a liquid)
+ // LiquidOut: floorY is liquid *end* (i.e. just out of a liquid)
+ TEnvType = (EAir, ELiquid, EWall); // where particle is now
+
+ // note: this MUST be record, so we can keep it in
+ // dynamic array and has sequential memory access pattern
+ PParticle = ^TParticle;
+ TParticle = record
+ x, y: Integer;
+ oldX, oldY: Integer;
+ velX, velY: Single;
+ accelX, accelY: Single;
+ state: TPartState;
+ particleType: TPartType;
+ red, green, blue: Byte;
+ alpha: Byte;
+ time, liveTime, waitTime: Word;
+ stickDX: Integer; // STATE_STICK: -1,1: stuck to a wall; 0: stuck to ceiling
+ justSticked: Boolean; // not used
+ floorY: Integer; // actually, floor-1; `Unknown`: unknown
+ floorType: TFloorType;
+ env: TEnvType; // where particle is now
+ ceilingY: Integer; // actually, ceiling+1; `Unknown`: unknown
+ wallEndY: Integer; // if we stuck to a wall, this is where wall ends
+
+ //k8: sorry, i have to emulate virtual methods this way, 'cause i haet `Object`
+ procedure thinkerBloodAndWater ();
+ procedure thinkerSpark ();
+ procedure thinkerBubble ();
+
+ procedure findFloor (force: Boolean=false); // this updates `floorY` if forced or Unknown
+ procedure findCeiling (force: Boolean=false); // this updates `ceilingY` if forced or Unknown
+
+ procedure freeze (); inline; // remove velocities and acceleration
+ procedure sleep (); inline; // switch to sleep mode
+
+ function checkAirStreams (): Boolean; // `true`: affected by air stream
+
+ function alive (): Boolean; inline;
+ procedure die (); inline;
+ procedure think (); inline;
+ end;
+
+ TOnceAnim = record
+ AnimType: Byte;
+ x, y: Integer;
+ oldX, oldY: Integer;
+ Animation: TAnimation;
+ end;
+
+ var (* private state *)
+ Particles: array of TParticle = nil;
+ OnceAnims: array of TOnceAnim = nil;
implementation
const
Unknown = Integer($7fffffff);
-
-type
- TPartType = (Blood, Spark, Bubbles, Water);
- TPartState = (Free, Normal, Stuck, Sleeping);
- TFloorType = (Wall, LiquidIn, LiquidOut);
- // Wall: floorY is just before floor
- // LiquidIn: floorY is liquid *start* (i.e. just in a liquid)
- // LiquidOut: floorY is liquid *end* (i.e. just out of a liquid)
- TEnvType = (EAir, ELiquid, EWall); // where particle is now
-
- // note: this MUST be record, so we can keep it in
- // dynamic array and has sequential memory access pattern
- PParticle = ^TParticle;
- TParticle = record
- x, y: Integer;
- oldX, oldY: Integer;
- velX, velY: Single;
- accelX, accelY: Single;
- state: TPartState;
- particleType: TPartType;
- red, green, blue: Byte;
- alpha: Byte;
- time, liveTime, waitTime: Word;
- stickDX: Integer; // STATE_STICK: -1,1: stuck to a wall; 0: stuck to ceiling
- justSticked: Boolean; // not used
- floorY: Integer; // actually, floor-1; `Unknown`: unknown
- floorType: TFloorType;
- env: TEnvType; // where particle is now
- ceilingY: Integer; // actually, ceiling+1; `Unknown`: unknown
- wallEndY: Integer; // if we stuck to a wall, this is where wall ends
-
- //k8: sorry, i have to emulate virtual methods this way, 'cause i haet `Object`
- procedure thinkerBloodAndWater ();
- procedure thinkerSpark ();
- procedure thinkerBubble ();
-
- procedure findFloor (force: Boolean=false); // this updates `floorY` if forced or Unknown
- procedure findCeiling (force: Boolean=false); // this updates `ceilingY` if forced or Unknown
-
- procedure freeze (); inline; // remove velocities and acceleration
- procedure sleep (); inline; // switch to sleep mode
-
- function checkAirStreams (): Boolean; // `true`: affected by air stream
-
- function alive (): Boolean; inline;
- procedure die (); inline;
- procedure think (); inline;
- end;
-
- TOnceAnim = record
- AnimType: Byte;
- x, y: Integer;
- oldX, oldY: Integer;
- Animation: TAnimation;
- end;
-
-
var
- Particles: array of TParticle = nil;
- OnceAnims: array of TOnceAnim = nil;
MaxParticles: Integer = 0;
CurrentParticle: Integer = 0;
// awakeMap has one bit for each map grid cell; on g_Mark,
end;
end;
-
-procedure g_GFX_Draw ();
- var
- a, len, fx, fy: Integer;
-begin
- if not gpart_dbg_enabled then exit;
-
- if (Particles <> nil) then
- begin
- glDisable(GL_TEXTURE_2D);
- if (g_dbg_scale < 0.6) then glPointSize(1)
- else if (g_dbg_scale > 1.3) then glPointSize(g_dbg_scale+1)
- else glPointSize(2);
- glDisable(GL_POINT_SMOOTH);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glBegin(GL_POINTS);
-
- len := High(Particles);
- for a := 0 to len do
- begin
- with Particles[a] do
- begin
- if not alive then continue;
- if (x >= sX) and (y >= sY) and (x <= sX+sWidth) and (sY <= sY+sHeight) then
- begin
- fx := nlerp(oldx, x, gLerpFactor);
- fy := nlerp(oldy, y, gLerpFactor);
- glColor4ub(red, green, blue, alpha);
- glVertex2f(fx+0.37, fy+0.37);
- end;
- end;
- end;
-
- glEnd();
-
- glDisable(GL_BLEND);
- end;
-
- if (OnceAnims <> nil) then
- begin
- len := High(OnceAnims);
- for a := 0 to len do
- begin
- if (OnceAnims[a].Animation <> nil) then
- begin
- with OnceAnims[a] do
- begin
- fx := nlerp(oldx, x, gLerpFactor);
- fy := nlerp(oldy, y, gLerpFactor);
- Animation.Draw(x, y, TMirrorType.None);
- end;
- end;
- end;
- end;
-end;
-
-
end.
index 5635ee4c394b74b970d00c2211aff242d988d72b..974731147b2cb0911748877183820fcd92be8e4f 100644 (file)
g_textures, e_input, e_sound,
g_language, g_console, g_menu, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, g_window,
g_items, g_weapons, g_gfx, g_phys, g_net, g_gui, g_netmaster,
- g_game, r_console
+ g_game, r_console, r_gfx
;
var
drawOther('monsters', @g_Monsters_Draw);
drawOther('itemdrop', @g_Items_DrawDrop);
drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door);
- drawOther('gfx', @g_GFX_Draw);
+ drawOther('gfx', @r_GFX_Draw);
drawOther('flags', @g_Map_DrawFlags);
drawPanelType('*acid1', PANEL_ACID1, g_rlayer_acid1);
drawPanelType('*acid2', PANEL_ACID2, g_rlayer_acid2);
diff --git a/src/game/opengl/r_gfx.pas b/src/game/opengl/r_gfx.pas
--- /dev/null
@@ -0,0 +1,91 @@
+(* Copyright (C) Doom 2D: Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../../shared/a_modes.inc}
+unit r_gfx;
+
+interface
+
+ procedure r_GFX_Draw;
+
+implementation
+
+ uses
+ {$INCLUDE ../nogl/noGLuses.inc}
+ SysUtils, Classes, Math,
+ utils,
+ e_graphics,
+ g_game,
+ g_gfx
+ ;
+
+procedure r_GFX_Draw;
+ var
+ a, len, fx, fy: Integer;
+begin
+ if not gpart_dbg_enabled then exit;
+
+ if (Particles <> nil) then
+ begin
+ glDisable(GL_TEXTURE_2D);
+ if (g_dbg_scale < 0.6) then glPointSize(1)
+ else if (g_dbg_scale > 1.3) then glPointSize(g_dbg_scale+1)
+ else glPointSize(2);
+ glDisable(GL_POINT_SMOOTH);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glBegin(GL_POINTS);
+
+ len := High(Particles);
+ for a := 0 to len do
+ begin
+ with Particles[a] do
+ begin
+ if not alive then continue;
+ if (x >= sX) and (y >= sY) and (x <= sX+sWidth) and (sY <= sY+sHeight) then
+ begin
+ fx := nlerp(oldx, x, gLerpFactor);
+ fy := nlerp(oldy, y, gLerpFactor);
+ glColor4ub(red, green, blue, alpha);
+ glVertex2f(fx+0.37, fy+0.37);
+ end;
+ end;
+ end;
+
+ glEnd();
+
+ glDisable(GL_BLEND);
+ end;
+
+ if (OnceAnims <> nil) then
+ begin
+ len := High(OnceAnims);
+ for a := 0 to len do
+ begin
+ if (OnceAnims[a].Animation <> nil) then
+ begin
+ with OnceAnims[a] do
+ begin
+ fx := nlerp(oldx, x, gLerpFactor);
+ fy := nlerp(oldy, y, gLerpFactor);
+ Animation.Draw(x, y, TMirrorType.None);
+ end;
+ end;
+ end;
+ end;
+end;
+
+end.