summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 292e2b4)
raw | patch | inline | side by side (parent: 292e2b4)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 7 Jun 2022 11:31:48 +0000 (14:31 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 08:39:33 +0000 (11:39 +0300) |
src/game/renders/opengl/r_map.pas | patch | blob | history | |
src/game/renders/opengl/r_render.pas | patch | blob | history |
index 063c36b91e628b048502af9c5d2116116eaa3db6..cd146a7b9fbeadd62a28e8058a1dc792beaf20ca 100644 (file)
procedure r_Map_LoadTextures;
procedure r_Map_FreeTextures;
+ procedure r_Map_NewGFX (typ, x, y: Integer);
+
procedure r_Map_Update;
procedure r_Map_Draw (x, y, w, h, camx, camy: Integer);
{$IFDEF ENABLE_CORPSES}
g_corpses,
{$ENDIF}
+ {$IFDEF ENABLE_GFX}
+ g_gfx,
+ {$ENDIF}
r_textures, r_draw
;
VILEFIRE_DX = 32;
VILEFIRE_DY = 128;
+ GFXAnim: array [0..R_GFX_LAST] of record
+ name: AnsiString;
+ w, h: Integer;
+ count: Integer;
+ back: Boolean;
+ speed: Integer;
+ rspeed: Integer;
+ alpha: Integer;
+ end = (
+ (name: ''; w: 0; h: 0; count: 0; back: false; speed: 0; rspeed: 0; alpha: 0),
+ (name: 'TELEPORT'; w: 64; h: 64; count: 10; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'FLAME'; w: 32; h: 32; count: 11; back: false; speed: 3; rspeed: 0; alpha: 0),
+ (name: 'EROCKET'; w: 128; h: 128; count: 6; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'EBFG'; w: 128; h: 128; count: 6; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'BFGHIT'; w: 64; h: 64; count: 4; back: false; speed: 4; rspeed: 0; alpha: 0),
+ (name: 'FIRE'; w: 64; h: 128; count: 8; back: false; speed: 4; rspeed: 2; alpha: 0),
+ (name: 'ITEMRESPAWN'; w: 32; h: 32; count: 5; back: true; speed: 4; rspeed: 0; alpha: 0),
+ (name: 'SMOKE'; w: 32; h: 32; count: 10; back: false; speed: 3; rspeed: 0; alpha: 0),
+ (name: 'ESKELFIRE'; w: 64; h: 64; count: 3; back: false; speed: 8; rspeed: 0; alpha: 0),
+ (name: 'EPLASMA'; w: 32; h: 32; count: 4; back: true; speed: 3; rspeed: 0; alpha: 0),
+ (name: 'EBSPFIRE'; w: 32; h: 32; count: 5; back: false; speed: 3; rspeed: 0; alpha: 0),
+ (name: 'EIMPFIRE'; w: 64; h: 64; count: 3; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'ECACOFIRE'; w: 64; h: 64; count: 3; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'EBARONFIRE'; w: 64; h: 64; count: 3; back: false; speed: 6; rspeed: 0; alpha: 0),
+ (name: 'TELEPORT'; w: 64; h: 64; count: 10; back: false; speed: 3; rspeed: 0; alpha: 0), // fast
+ (name: 'SMOKE'; w: 32; h: 32; count: 10; back: false; speed: 3; rspeed: 0; alpha: 150), // transparent
+ (name: 'FLAME'; w: 32; h: 32; count: 11; back: false; speed: 3; rspeed: 2; alpha: 0) // random
+ );
+
type
TBinHeapPanelDrawCmp = class
public
*)
end;
+{$IFDEF ENABLE_GFX}
+ GFXTextures: array [0..R_GFX_LAST] of TGLMultiTexture;
+ gfxlist: array of record
+ typ: Byte;
+ alpha: Byte;
+ x, y: Integer;
+ oldX, oldY: Integer;
+ anim: TAnimState;
+ end = nil;
+{$ENDIF}
+
plist: TBinHeapPanelDraw = nil;
class function TBinHeapPanelDrawCmp.less (const a, b: TPanel): Boolean; inline;
for j := 0 to W_POS_LAST do
for k := 0 to W_ACT_LAST do
WeapTextures[i, j, k] := r_Textures_LoadFromFile(GameWAD + ':WEAPONS\' + WeapName[i] + WeapPos[j] + WeapAct[k]);
+ // --------- gfx animations --------- //
+ {$IFDEF ENABLE_GFX}
+ for i := 1 to R_GFX_LAST do
+ GFXTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + GFXAnim[i].name, GFXAnim[i].w, GFXAnim[i].h, GFXAnim[i].count, GFXAnim[i].back);
+ {$ENDIF}
end;
procedure r_Map_Free;
var i, j, k, a: Integer; d: TDirection;
begin
+ {$IFDEF ENABLE_GFX}
+ gfxlist := nil;
+ for i := 0 to R_GFX_LAST do
+ begin
+ if GFXTextures[i] <> nil then
+ GFXTextures[i].Free;
+ GFXTextures[i] := nil;
+ end;
+ {$ENDIF}
for i := 1 to WP_LAST do
begin
for j := 0 to W_POS_LAST do
RenTextures := nil;
end;
- procedure r_Map_Update;
- var i: Integer;
- begin
- for i := 0 to ITEM_MAX do
- Items[i].anim.Update;
- end;
-
procedure r_Map_DrawPanel (p: TPanel);
var Texture: Integer; t: TGLMultiTexture;
begin
end;
{$ENDIF}
+{$IFDEF ENABLE_GFX}
+ function r_Map_GetGFXID (): Integer;
+ var i: Integer;
+ begin
+ i := 0;
+ if gfxlist <> nil then
+ begin
+ while (i < Length(gfxlist)) and gfxlist[i].anim.IsValid() do
+ Inc(i);
+ if i >= Length(gfxlist) then
+ SetLength(gfxlist, Length(gfxlist) + 1)
+ end
+ else
+ SetLength(gfxlist, 1);
+ gfxlist[i].typ := R_GFX_NONE;
+ gfxlist[i].anim.Invalidate;
+ result := i
+ end;
+
+ procedure r_Map_NewGFX (typ, x, y: Integer);
+ var i: Integer;
+ begin
+ if gpart_dbg_enabled and (typ > 0) and (typ <= R_GFX_LAST) then
+ begin
+ i := r_Map_GetGFXID();
+ if i >= 0 then
+ begin
+ gfxlist[i].typ := typ;
+ gfxlist[i].x := x;
+ gfxlist[i].y := y;
+ gfxlist[i].oldX := x;
+ gfxlist[i].oldY := y;
+ gfxlist[i].anim := TAnimState.Create(false, GFXAnim[typ].speed + Random(GFXAnim[typ].rspeed), GFXAnim[typ].count);
+ gfxlist[i].anim.Reset();
+ gfxlist[i].anim.Enable();
+ end;
+ end;
+ end;
+
+ procedure r_Map_UpdateGFX;
+ var i: Integer;
+ begin
+ if gfxlist <> nil then
+ begin
+ for i := 0 to High(gfxlist) do
+ begin
+ if gfxlist[i].anim.IsValid() then
+ begin
+ gfxlist[i].oldX := gfxlist[i].x;
+ gfxlist[i].oldY := gfxlist[i].y;
+ case gfxlist[i].typ of
+ R_GFX_FLAME, R_GFX_SMOKE:
+ begin
+ if Random(3) = 0 then
+ gfxlist[i].x := gfxlist[i].x - 1 + Random(3);
+ if Random(2) = 0 then
+ gfxlist[i].y := gfxlist[i].y - Random(2);
+ end;
+ end;
+ if gfxlist[i].anim.played then
+ gfxlist[i].anim.Invalidate
+ else
+ gfxlist[i].anim.Update
+ end;
+ end;
+ end;
+ end;
+
+ procedure r_Map_DrawParticles (x, y, w, h: Integer);
+ var i, fx, fy: Integer;
+ begin
+ if gpart_dbg_enabled and (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);
+ for i := 0 to High(Particles) do
+ begin
+ if Particles[i].alive then
+ begin
+ fx := nlerp(Particles[i].oldX, Particles[i].x, gLerpFactor);
+ fy := nlerp(Particles[i].oldY, Particles[i].y, gLerpFactor);
+ glColor4ub(Particles[i].red, Particles[i].green, Particles[i].blue, Particles[i].alpha);
+ glVertex2f(fx, fy);
+ end;
+ end;
+ glEnd;
+
+ glDisable(GL_BLEND);
+ end;
+ end;
+
+ procedure r_Map_DrawGFX (x, y, w, h: Integer);
+ var i, fx, fy, typ: Integer; tex: TGLMultiTexture;
+ begin
+ if gfxlist <> nil then
+ begin
+ for i := 0 to High(gfxlist) do
+ begin
+ if gfxlist[i].anim.IsValid() then
+ begin
+ typ := gfxlist[i].typ;
+ tex := GFXTextures[typ];
+ if tex <> nil then
+ begin
+ fx := nlerp(gfxlist[i].oldX, gfxlist[i].x, gLerpFactor);
+ fy := nlerp(gfxlist[i].oldY, gfxlist[i].y, gLerpFactor);
+ // TODO set GFXAnim[typ].alpha
+ r_Draw_MultiTextureRepeat(tex, gfxlist[i].anim, fx, fy, tex.width, tex.height, false);
+ end;
+ end;
+ end;
+ end;
+ end;
+{$ENDIF}
+
procedure r_Map_Draw (x, y, w, h, camx, camy: Integer);
var iter: TPanelGrid.Iter; p: PPanel; cx, cy, xx, yy, ww, hh: Integer;
begin
r_Map_DrawMonsters(xx, yy, ww, hh);
r_Map_DrawItems(xx, yy, ww, hh, true);
r_Map_DrawPanelType(PANEL_CLOSEDOOR);
- // TODO draw gfx
+ {$IFDEF ENABLE_GFX}
+ r_Map_DrawParticles(xx, yy, ww, hh);
+ r_Map_DrawGFX(xx, yy, ww, hh);
+ {$ENDIF}
// TODO draw flags
r_Map_DrawPanelType(PANEL_ACID1);
r_Map_DrawPanelType(PANEL_ACID2);
glPopMatrix;
end;
+ procedure r_Map_Update;
+ var i: Integer;
+ begin
+ for i := 0 to ITEM_MAX do
+ Items[i].anim.Update;
+ r_Map_UpdateGFX;
+ end;
+
end.
index 568b8b893e6c0b27a22445d5f19a5bdd18f08fc2..98b5d8b916dd0b4ee3e751946f6d879d24180e69 100644 (file)
{$IFDEF ENABLE_GFX}
procedure r_Render_QueueEffect (AnimType, X, Y: Integer);
begin
+ r_Map_NewGFX(AnimType, X, Y);
end;
{$ENDIF}