mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
uint64_t based FPS limiter
git-svn-id: https://svn.eduke32.com/eduke32@6441 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
60d06d8757
commit
389c71e185
4 changed files with 11 additions and 10 deletions
|
@ -120,7 +120,7 @@ int32_t hud_showmapname = 1;
|
||||||
int32_t g_levelTextTime = 0;
|
int32_t g_levelTextTime = 0;
|
||||||
|
|
||||||
int32_t r_maxfps = 60;
|
int32_t r_maxfps = 60;
|
||||||
uint32_t g_frameDelay = 17;
|
uint64_t g_frameDelay = 17;
|
||||||
|
|
||||||
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
|
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
|
||||||
extern char forcegl;
|
extern char forcegl;
|
||||||
|
@ -6077,7 +6077,8 @@ void G_MaybeAllocPlayer(int32_t pnum)
|
||||||
|
|
||||||
int G_FPSLimit(void)
|
int G_FPSLimit(void)
|
||||||
{
|
{
|
||||||
static uint32_t nextRender = 0, frameWaiting = 0;
|
static uint64_t nextPageTicks = 0;
|
||||||
|
static int frameWaiting = 0;
|
||||||
|
|
||||||
if (frameWaiting)
|
if (frameWaiting)
|
||||||
{
|
{
|
||||||
|
@ -6085,14 +6086,14 @@ int G_FPSLimit(void)
|
||||||
nextpage();
|
nextpage();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t frameTime = getticks();
|
uint64_t const frameTicks = getu64ticks();
|
||||||
|
|
||||||
if (r_maxfps == 0 || frameTime >= nextRender)
|
if (r_maxfps == 0 || frameTicks >= nextPageTicks)
|
||||||
{
|
{
|
||||||
if (frameTime > nextRender + g_frameDelay)
|
if (frameTicks >= nextPageTicks + g_frameDelay)
|
||||||
nextRender = frameTime;
|
nextPageTicks = frameTicks;
|
||||||
|
|
||||||
nextRender += g_frameDelay;
|
nextPageTicks += g_frameDelay;
|
||||||
frameWaiting++;
|
frameWaiting++;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -290,7 +290,7 @@ extern int32_t MAXCACHE1DSIZE;
|
||||||
extern palette_t CrosshairColors;
|
extern palette_t CrosshairColors;
|
||||||
extern palette_t DefaultCrosshairColors;
|
extern palette_t DefaultCrosshairColors;
|
||||||
|
|
||||||
extern uint32_t g_frameDelay;
|
extern uint64_t g_frameDelay;
|
||||||
|
|
||||||
int32_t A_CheckInventorySprite(spritetype *s);
|
int32_t A_CheckInventorySprite(spritetype *s);
|
||||||
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
|
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
|
||||||
|
|
|
@ -2945,7 +2945,7 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption)
|
||||||
}
|
}
|
||||||
else if (entry == &ME_VIDEOSETUP_FRAMELIMIT)
|
else if (entry == &ME_VIDEOSETUP_FRAMELIMIT)
|
||||||
{
|
{
|
||||||
g_frameDelay = newOption ? Blrintf(1000.f/(float) newOption) : 0;
|
g_frameDelay = newOption ? (getu64tickspersec()/newOption) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (g_currentMenu)
|
switch (g_currentMenu)
|
||||||
|
|
|
@ -1424,7 +1424,7 @@ static int32_t osdcmd_cvar_set_game(osdfuncparm_t const * const parm)
|
||||||
else if (!Bstrcasecmp(parm->name, "r_maxfps"))
|
else if (!Bstrcasecmp(parm->name, "r_maxfps"))
|
||||||
{
|
{
|
||||||
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);
|
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);
|
||||||
g_frameDelay = r_maxfps ? Blrintf(1000.f/(float)r_maxfps) : 0;
|
g_frameDelay = r_maxfps ? (getu64tickspersec()/r_maxfps) : 0;
|
||||||
}
|
}
|
||||||
else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
|
else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue