mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- more work to switch over to the new loop.
Mainly separation of ticker and render calls
This commit is contained in:
parent
367b4ce051
commit
0c455acaa2
10 changed files with 93 additions and 56 deletions
|
@ -74,7 +74,6 @@ enum rendmode_t {
|
||||||
|
|
||||||
#define MAXVOXELS 1024
|
#define MAXVOXELS 1024
|
||||||
#define MAXSTATUS 1024
|
#define MAXSTATUS 1024
|
||||||
#define MAXPLAYERS 16
|
|
||||||
// Maximum number of component tiles in a multi-psky:
|
// Maximum number of component tiles in a multi-psky:
|
||||||
#define MAXPSKYTILES 16
|
#define MAXPSKYTILES 16
|
||||||
#define MAXSPRITESONSCREEN 2560
|
#define MAXSPRITESONSCREEN 2560
|
||||||
|
|
|
@ -53,6 +53,8 @@ void Net_SkipCommand (int type, uint8_t **stream);
|
||||||
|
|
||||||
void Net_ClearBuffers ();
|
void Net_ClearBuffers ();
|
||||||
|
|
||||||
|
bool D_CheckNetGame(void);
|
||||||
|
|
||||||
|
|
||||||
// Netgame stuff (buffers and pointers, i.e. indices).
|
// Netgame stuff (buffers and pointers, i.e. indices).
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "screenjob.h"
|
#include "screenjob.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "uiinput.h"
|
#include "uiinput.h"
|
||||||
|
#include "d_net.h"
|
||||||
|
|
||||||
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
@ -100,6 +101,7 @@ int lastTic;
|
||||||
|
|
||||||
int automapMode;
|
int automapMode;
|
||||||
bool automapFollow;
|
bool automapFollow;
|
||||||
|
extern int pauseext;
|
||||||
|
|
||||||
CCMD(togglemap)
|
CCMD(togglemap)
|
||||||
{
|
{
|
||||||
|
@ -137,6 +139,7 @@ void I_DetectOS(void);
|
||||||
void LoadScripts();
|
void LoadScripts();
|
||||||
void app_loop();
|
void app_loop();
|
||||||
void DrawFullscreenBlends();
|
void DrawFullscreenBlends();
|
||||||
|
void MainLoop();
|
||||||
|
|
||||||
|
|
||||||
bool AppActive;
|
bool AppActive;
|
||||||
|
@ -280,15 +283,6 @@ void UserConfig::ProcessOptions()
|
||||||
Printf("Build-format config files not supported and will be ignored\n");
|
Printf("Build-format config files not supported and will be ignored\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // MP disabled pending evaluation
|
|
||||||
auto v = Args->CheckValue("-port");
|
|
||||||
if (v) netPort = strtol(v, nullptr, 0);
|
|
||||||
|
|
||||||
netServerMode = Args->CheckParm("-server");
|
|
||||||
netServerAddress = Args->CheckValue("-connect");
|
|
||||||
netPassword = Args->CheckValue("-password");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto v = Args->CheckValue("-addon");
|
auto v = Args->CheckValue("-addon");
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
|
@ -866,9 +860,9 @@ int RunGame()
|
||||||
auto exec = C_ParseCmdLineParams(nullptr);
|
auto exec = C_ParseCmdLineParams(nullptr);
|
||||||
if (exec) exec->ExecCommands();
|
if (exec) exec->ExecCommands();
|
||||||
|
|
||||||
gamestate = GS_LEVEL;
|
|
||||||
SetupGameButtons();
|
SetupGameButtons();
|
||||||
gi->app_init();
|
gi->app_init();
|
||||||
|
|
||||||
app_loop();
|
app_loop();
|
||||||
return 0; // this is never reached. app_loop only exits via exception.
|
return 0; // this is never reached. app_loop only exits via exception.
|
||||||
}
|
}
|
||||||
|
@ -1150,6 +1144,15 @@ void S_SetSoundPaused(int state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!netgame
|
||||||
|
#if 0 //def _DEBUG
|
||||||
|
&& !demoplayback
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pauseext = !state;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FString G_GetDemoPath()
|
FString G_GetDemoPath()
|
||||||
|
|
|
@ -98,6 +98,11 @@ int oldentertics;
|
||||||
int gametic;
|
int gametic;
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
void G_BuildTiccmd(ticcmd_t* cmd)
|
void G_BuildTiccmd(ticcmd_t* cmd)
|
||||||
{
|
{
|
||||||
|
@ -105,8 +110,13 @@ void G_BuildTiccmd(ticcmd_t* cmd)
|
||||||
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS];
|
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
void G_Ticker()
|
static void GameTicker()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -116,11 +126,6 @@ void G_Ticker()
|
||||||
// Todo: Migrate state changes to here instead of doing them ad-hoc
|
// Todo: Migrate state changes to here instead of doing them ad-hoc
|
||||||
while (gameaction != ga_nothing)
|
while (gameaction != ga_nothing)
|
||||||
{
|
{
|
||||||
if (gameaction == ga_newgame2)
|
|
||||||
{
|
|
||||||
gameaction = ga_newgame;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (gameaction)
|
switch (gameaction)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -181,18 +186,15 @@ void G_Ticker()
|
||||||
gi->Startup();
|
gi->Startup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GS_MENUSCREEN:
|
|
||||||
case GS_FULLCONSOLE:
|
|
||||||
gi->DrawBackground();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GS_LEVEL:
|
case GS_LEVEL:
|
||||||
gi->Ticker();
|
gi->Ticker();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GS_MENUSCREEN:
|
||||||
|
case GS_FULLCONSOLE:
|
||||||
case GS_INTERMISSION:
|
case GS_INTERMISSION:
|
||||||
case GS_INTRO:
|
case GS_INTRO:
|
||||||
RunScreenJobFrame();
|
// These elements do not tick at game rate.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -201,54 +203,65 @@ void G_Ticker()
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// D_Display
|
// Display
|
||||||
//
|
|
||||||
// Draw current display, possibly wiping it from the previous
|
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void D_Display()
|
void Display()
|
||||||
{
|
{
|
||||||
FGameTexture* wipe = nullptr;
|
if (screen == nullptr || !AppActive && (screen->IsFullscreen() || !vid_activeinbackground))
|
||||||
|
|
||||||
if (screen == NULL)
|
|
||||||
return; // for comparative timing / profiling
|
|
||||||
|
|
||||||
if (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->FrameTime = I_msTimeFS();
|
screen->FrameTime = I_msTimeFS();
|
||||||
screen->BeginFrame();
|
screen->BeginFrame();
|
||||||
|
twodpsp.ClearClipRect();
|
||||||
twod->ClearClipRect();
|
twod->ClearClipRect();
|
||||||
if ((gamestate == GS_LEVEL) && gametic != 0)
|
switch (gamestate)
|
||||||
{
|
{
|
||||||
// [ZZ] execute event hook that we just started the frame
|
case GS_MENUSCREEN:
|
||||||
//E_RenderFrame();
|
gi->DrawBackground();
|
||||||
//
|
break;
|
||||||
gi->Render();
|
|
||||||
|
case GS_FINALE:
|
||||||
|
// screen jobs are not bound by the game ticker so they need to be ticked in the display loop.
|
||||||
|
RunScreenJobFrame();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GS_LEVEL:
|
||||||
|
if (gametic != 0)
|
||||||
|
{
|
||||||
|
gi->Render();
|
||||||
|
DrawFullscreenBlends();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw overlay elements to the 2D drawer
|
|
||||||
NetUpdate(); // send out any new accumulation
|
NetUpdate(); // send out any new accumulation
|
||||||
|
|
||||||
|
// Draw overlay elements
|
||||||
CT_Drawer();
|
CT_Drawer();
|
||||||
C_DrawConsole();
|
C_DrawConsole();
|
||||||
M_Drawer();
|
M_Drawer();
|
||||||
FStat::PrintStat(twod);
|
FStat::PrintStat(twod);
|
||||||
|
|
||||||
// Handle the final 2D overlays.
|
|
||||||
if (gamestate == GS_LEVEL) DrawFullscreenBlends();
|
|
||||||
DrawRateStuff();
|
DrawRateStuff();
|
||||||
|
|
||||||
videoShowFrame(0);
|
videoShowFrame(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
// Forces playsim processing time to be consistent across frames.
|
// Forces playsim processing time to be consistent across frames.
|
||||||
// This improves interpolation for frames in between tics.
|
// This improves interpolation for frames in between tics.
|
||||||
//
|
//
|
||||||
// With this cvar off the mods with a high playsim processing time will appear
|
// With this cvar off the mods with a high playsim processing time will appear
|
||||||
// less smooth as the measured time used for interpolation will vary.
|
// less smooth as the measured time used for interpolation will vary.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
static void TicStabilityWait()
|
static void TicStabilityWait()
|
||||||
{
|
{
|
||||||
|
@ -280,9 +293,12 @@ static void TicStabilityEnd()
|
||||||
stabilityticduration = std::min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000);
|
stabilityticduration = std::min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// TryRunTics
|
// The most important function in the engine.
|
||||||
//
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
void TryRunTics (void)
|
void TryRunTics (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -296,7 +312,7 @@ void TryRunTics (void)
|
||||||
// will all be wasted anyway.
|
// will all be wasted anyway.
|
||||||
if (pauseext)
|
if (pauseext)
|
||||||
r_NoInterpolate = true;
|
r_NoInterpolate = true;
|
||||||
bool doWait = cl_capfps || r_NoInterpolate /*|| netgame*/;
|
bool doWait = cl_capfps || r_NoInterpolate;
|
||||||
|
|
||||||
// get real tics
|
// get real tics
|
||||||
if (doWait)
|
if (doWait)
|
||||||
|
@ -328,14 +344,7 @@ void TryRunTics (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticdup == 1)
|
availabletics = lowtic - gametic / ticdup;
|
||||||
{
|
|
||||||
availabletics = lowtic - gametic;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
availabletics = lowtic - gametic / ticdup;
|
|
||||||
}
|
|
||||||
|
|
||||||
// decide how many tics to run
|
// decide how many tics to run
|
||||||
if (realtics < availabletics-1)
|
if (realtics < availabletics-1)
|
||||||
|
@ -362,6 +371,7 @@ void TryRunTics (void)
|
||||||
gi->Predict(myconnectindex);
|
gi->Predict(myconnectindex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
gi->GetInput(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,10 +441,9 @@ void TryRunTics (void)
|
||||||
D_DoAdvanceDemo ();
|
D_DoAdvanceDemo ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//if (debugfile) fprintf (debugfile, "run tic %d\n", gametic);
|
|
||||||
C_Ticker ();
|
C_Ticker ();
|
||||||
M_Ticker ();
|
M_Ticker ();
|
||||||
G_Ticker();
|
GameTicker();
|
||||||
gametic++;
|
gametic++;
|
||||||
|
|
||||||
NetUpdate (); // check for new console commands
|
NetUpdate (); // check for new console commands
|
||||||
|
@ -482,7 +491,7 @@ void MainLoop ()
|
||||||
// Update display, next frame, with current state.
|
// Update display, next frame, with current state.
|
||||||
I_StartTic ();
|
I_StartTic ();
|
||||||
|
|
||||||
D_Display();
|
Display();
|
||||||
Mus_UpdateMusic(); // must be at the end.
|
Mus_UpdateMusic(); // must be at the end.
|
||||||
}
|
}
|
||||||
catch (CRecoverableError &error)
|
catch (CRecoverableError &error)
|
||||||
|
|
|
@ -59,6 +59,10 @@ struct GameInterface : public ::GameInterface
|
||||||
void ResetFollowPos(bool message) override;
|
void ResetFollowPos(bool message) override;
|
||||||
void GetInput(InputPacket* packet) override;
|
void GetInput(InputPacket* packet) override;
|
||||||
void UpdateSounds() override;
|
void UpdateSounds() override;
|
||||||
|
void Startup() override;
|
||||||
|
void DrawBackground() override;
|
||||||
|
void Render() override;
|
||||||
|
void Ticker() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,24 @@ static void Startup()
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GameInterface::Startup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameInterface::DrawBackground()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameInterface::Render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameInterface::Ticker()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameInterface::RunGameFrame()
|
void GameInterface::RunGameFrame()
|
||||||
{
|
{
|
||||||
switch (gamestate)
|
switch (gamestate)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "d_net.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
#include "d_net.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GLInstance GLInterface;
|
extern GLInstance GLInterface;
|
||||||
|
extern F2DDrawer twodpsp;
|
||||||
|
|
||||||
void renderSetProjectionMatrix(const float* p);
|
void renderSetProjectionMatrix(const float* p);
|
||||||
void renderSetViewMatrix(const float* p);
|
void renderSetViewMatrix(const float* p);
|
||||||
|
|
|
@ -2057,7 +2057,6 @@ extern short numplayers, myconnectindex;
|
||||||
extern short connecthead, connectpoint2[MAXPLAYERS];
|
extern short connecthead, connectpoint2[MAXPLAYERS];
|
||||||
*/
|
*/
|
||||||
extern int *lastpacket2clock;
|
extern int *lastpacket2clock;
|
||||||
extern char username[MAXPLAYERS][50];
|
|
||||||
|
|
||||||
// save player info when moving to a new level
|
// save player info when moving to a new level
|
||||||
extern USER puser[MAX_SW_PLAYERS_REG];
|
extern USER puser[MAX_SW_PLAYERS_REG];
|
||||||
|
|
Loading…
Reference in a new issue