- moved the wipe loop out of d_main.cpp into f_wipe.cpp

As preparation fior fully moving it into the backend
This commit is contained in:
Christoph Oelckers 2022-04-25 17:30:20 +02:00
parent 7b59293995
commit ccdf5fb23c
6 changed files with 70 additions and 54 deletions

View file

@ -29,10 +29,4 @@ void I_PolyPresentUnlock(int x, int y, int w, int h);
void I_PolyPresentDeinit();
// Pause a bit.
// [RH] Despite the name, it apparently never waited for the VBL, even in
// the original DOS version (if the Heretic/Hexen source is any indicator).
void I_WaitVBL(int count);
#endif // __I_VIDEO_H__

View file

@ -44,3 +44,8 @@ double I_GetInputFrac(bool const synchronised, double const ticrate = GameTicRat
// Reset the last input check to after a lengthy operation
void I_ResetInputTime();
// Pause a bit.
// [RH] Despite the name, it apparently never waited for the VBL, even in
// the original DOS version (if the Heretic/Hexen source is any indicator).
void I_WaitVBL(int count);

View file

@ -823,9 +823,18 @@ static void DrawRateStuff()
}
}
static void DrawOverlays()
{
NetUpdate ();
C_DrawConsole ();
M_Drawer ();
DrawRateStuff();
if (!hud_toggled)
FStat::PrintStat (twod);
}
static void End2DAndUpdate()
{
DrawRateStuff();
twod->End();
CheckBench();
screen->Update();
@ -842,7 +851,7 @@ static void End2DAndUpdate()
void D_Display ()
{
FGameTexture *wipe = nullptr;
FTexture *wipestart = nullptr;
int wipe_type;
sector_t *viewsec;
@ -908,7 +917,7 @@ void D_Display ()
if (NoWipe)
{
NoWipe--;
wipe = nullptr;
wipestart = nullptr;
wipegamestate = gamestate;
}
// No wipes when in a stereo3D VR mode
@ -917,7 +926,7 @@ void D_Display ()
if (vr_mode == 0 || vid_rendermode != 4)
{
// save the current screen if about to wipe
wipe = MakeGameTexture(screen->WipeStartScreen(), nullptr, ETextureType::SWCanvas);
wipestart = screen->WipeStartScreen();
switch (wipegamestate)
{
@ -943,7 +952,7 @@ void D_Display ()
}
else
{
wipe = nullptr;
wipestart = nullptr;
}
screen->FrameTime = I_msTimeFS();
@ -1089,54 +1098,17 @@ void D_Display ()
}
}
if (!wipe || NoWipe < 0 || wipe_type == wipe_None || hud_toggled)
if (!wipestart || NoWipe < 0 || wipe_type == wipe_None || hud_toggled)
{
if (wipe != nullptr) delete wipe;
wipe = nullptr;
NetUpdate (); // send out any new accumulation
// normal update
// draw ZScript UI stuff
C_DrawConsole (); // draw console
M_Drawer (); // menu is drawn even on top of everything
if (!hud_toggled)
FStat::PrintStat (twod);
if (wipestart != nullptr) wipestart->DecRef();
wipestart = nullptr;
DrawOverlays();
End2DAndUpdate ();
}
else
{
// wipe update
uint64_t wipestart, nowtime, diff;
bool done;
GSnd->SetSfxPaused(true, 1);
I_FreezeTime(true);
twod->End();
auto wipend = MakeGameTexture(screen->WipeEndScreen(), nullptr, ETextureType::SWCanvas);
auto wiper = Wiper::Create(wipe_type);
wiper->SetTextures(wipe, wipend);
wipestart = I_msTime();
NetUpdate(); // send out any new accumulation
do
{
do
{
I_WaitVBL(2);
nowtime = I_msTime();
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
} while (diff < 1);
wipestart = nowtime;
twod->Begin(screen->GetWidth(), screen->GetHeight());
done = wiper->Run(1);
C_DrawConsole (); // console and
M_Drawer (); // menu are drawn even on top of wipes
End2DAndUpdate ();
NetUpdate (); // [RH] not sure this is needed anymore
} while (!done);
delete wiper;
I_FreezeTime(false);
GSnd->SetSfxPaused(false, 1);
PerformWipe(wipestart, screen->WipeEndScreen(), wipe_type, false, DrawOverlays);
}
cycles.Unclock();
FrameCycles = cycles;

View file

@ -64,6 +64,7 @@
#include "gameconfigfile.h"
#include "d_player.h"
#include "teaminfo.h"
#include "i_time.h"
#include "hwrenderer/scene/hw_drawinfo.h"
EXTERN_CVAR(Int, cl_gfxlocalization)
@ -77,7 +78,6 @@ CVAR(Bool, m_simpleoptions, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
typedef void(*hfunc)();
DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr);
bool OkForLocalization(FTextureID texnum, const char* substitute);
void I_WaitVBL(int count);
FNewGameStartup NewGameStartupInfo;

View file

@ -30,6 +30,8 @@
#include "bitmap.h"
#include "hw_material.h"
#include "v_draw.h"
#include "s_soundinternal.h"
#include "i_time.h"
class FBurnTexture : public FTexture
{
@ -396,3 +398,44 @@ bool Wiper_Burn::Run(int ticks)
// after an arbitrary maximum time.
return done || (BurnTime > 40);
}
void PerformWipe(FTexture* startimg, FTexture* endimg, int wipe_type, bool stopsound, std::function<void()> overlaydrawer)
{
// wipe update
uint64_t wipestart, nowtime, diff;
bool done;
GSnd->SetSfxPaused(true, 1);
I_FreezeTime(true);
twod->End();
assert(startimg != nullptr && endimg != nullptr);
auto starttex = MakeGameTexture(startimg, nullptr, ETextureType::SWCanvas);
auto endtex = MakeGameTexture(endimg, nullptr, ETextureType::SWCanvas);
auto wiper = Wiper::Create(wipe_type);
wiper->SetTextures(starttex, endtex);
wipestart = I_msTime();
do
{
do
{
I_WaitVBL(2);
nowtime = I_msTime();
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
} while (diff < 1);
wipestart = nowtime;
twod->Begin(screen->GetWidth(), screen->GetHeight());
done = wiper->Run(1);
if (overlaydrawer) overlaydrawer();
twod->End();
screen->Update();
twod->OnFrameDone();
} while (!done);
delete wiper;
I_FreezeTime(false);
GSnd->SetSfxPaused(false, 1);
}

View file

@ -56,5 +56,7 @@ public:
static Wiper *Create(int type);
};
void PerformWipe(FTexture* startimg, FTexture* endimg, int wipe_type, bool stopsound, std::function<void()> overlaydrawer);
#endif