From: DeaDDooMER Date: Wed, 8 Jun 2022 11:20:57 +0000 (+0300) Subject: gl: rotate shots X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=16f3b052ce6fc16344961a11ab066795f7df7711;p=d2df-sdl.git gl: rotate shots --- diff --git a/src/game/renders/opengl/r_draw.pas b/src/game/renders/opengl/r_draw.pas index d76f493..3790800 100644 --- a/src/game/renders/opengl/r_draw.pas +++ b/src/game/renders/opengl/r_draw.pas @@ -26,6 +26,7 @@ interface procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean); procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const a: TAnimState; x, y, w, h: Integer; flip: Boolean); + procedure r_Draw_MultiTextureRepeatRotate (img: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; rx, ry, a: Integer); procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte); @@ -192,6 +193,24 @@ implementation end end; + procedure r_Draw_MultiTextureRepeatRotate (img: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; rx, ry, a: Integer); + var i, j: Integer; + begin + ASSERT(w >= 0); + ASSERT(h >= 0); + if a <> 0 then + begin + glPushMatrix; + glTranslatef(x + rx, y + ry, 0); + glRotatef(a, 0, 0, 1); + glTranslatef(-(x + rx), -(y + ry), 0); + r_Draw_MultiTextureRepeat(img, anim, x, y, w, h, flip); + glPopMatrix; + end + else + r_Draw_MultiTextureRepeat(img, anim, x, y, w, h, flip); + end; + procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte); begin ASSERT(r >= l); diff --git a/src/game/renders/opengl/r_map.pas b/src/game/renders/opengl/r_map.pas index 4837e1b..0588f0d 100644 --- a/src/game/renders/opengl/r_map.pas +++ b/src/game/renders/opengl/r_map.pas @@ -861,11 +861,9 @@ implementation typ := Shots[i].ShotType; if typ <> 0 then begin - e_logwritefln('draw shot %s typ %s', [i, typ]); tex := ShotTextures[typ]; if tex <> nil then begin - e_logwritefln('draw shot %s typ %s <> nil', [i, typ]); a := 0; case typ of WEAPON_ROCKETLAUNCHER, WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE: @@ -874,10 +872,9 @@ implementation Shots[i].Obj.Lerp(gLerpFactor, fX, fY); pX := Shots[i].Obj.Rect.Width div 2; pY := Shots[i].Obj.Rect.Height div 2; - // TODO fix this + // TODO fix this hack if Shots[i].Animation.IsValid() then anim := @Shots[i].Animation else anim := @StubShotAnim; - // TODO: change angle and base point - r_Draw_MultiTextureRepeat(tex, anim^, fX, fY, tex.width, tex.height, false); + r_Draw_MultiTextureRepeatRotate(tex, anim^, fX, fY, tex.width, tex.height, false, pX, pY, a); end; end; end;