mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-28 18:50:45 +00:00
screen: Add show_fps feature to NQ
Same as available in QW, activate with cvar show_fps. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
0947565f7f
commit
d71439deeb
@ -306,6 +306,8 @@ void CL_NextDemo(void);
|
||||
extern int cl_numvisedicts;
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
|
||||
extern int fps_count;
|
||||
|
||||
//
|
||||
// cl_input
|
||||
//
|
||||
|
@ -97,6 +97,7 @@ cvar_t scr_showturtle = { "showturtle", "0" };
|
||||
cvar_t scr_showpause = { "showpause", "1" };
|
||||
cvar_t scr_printspeed = { "scr_printspeed", "8" };
|
||||
cvar_t gl_triplebuffer = { "gl_triplebuffer", "1", true };
|
||||
static cvar_t show_fps = { "show_fps", "0" }; /* set for running times */
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
||||
@ -382,6 +383,7 @@ SCR_Init(void)
|
||||
Cvar_RegisterVariable(&scr_centertime);
|
||||
Cvar_RegisterVariable(&scr_printspeed);
|
||||
Cvar_RegisterVariable(&gl_triplebuffer);
|
||||
Cvar_RegisterVariable(&show_fps);
|
||||
|
||||
Cmd_AddCommand("screenshot", SCR_ScreenShot_f);
|
||||
Cmd_AddCommand("sizeup", SCR_SizeUp_f);
|
||||
@ -456,6 +458,32 @@ SCR_DrawNet(void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SCR_DrawFPS(void)
|
||||
{
|
||||
static double lastframetime;
|
||||
double t;
|
||||
static int lastfps;
|
||||
int x, y;
|
||||
char st[80];
|
||||
|
||||
if (!show_fps.value)
|
||||
return;
|
||||
|
||||
t = Sys_DoubleTime();
|
||||
if ((t - lastframetime) >= 1.0) {
|
||||
lastfps = fps_count;
|
||||
fps_count = 0;
|
||||
lastframetime = t;
|
||||
}
|
||||
|
||||
sprintf(st, "%3d FPS", lastfps);
|
||||
x = vid.width - strlen(st) * 8 - 16;
|
||||
y = vid.height - sb_lines - 8;
|
||||
Draw_String(x, y, st);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
DrawPause
|
||||
@ -897,6 +925,7 @@ SCR_UpdateScreen(void)
|
||||
}
|
||||
SCR_DrawRam();
|
||||
SCR_DrawNet();
|
||||
SCR_DrawFPS();
|
||||
SCR_DrawTurtle();
|
||||
SCR_DrawPause();
|
||||
SCR_CheckDrawCenterString();
|
||||
|
@ -70,6 +70,8 @@ int minimum_memory;
|
||||
|
||||
client_t *host_client; // current client
|
||||
|
||||
int fps_count;
|
||||
|
||||
static jmp_buf host_abort;
|
||||
|
||||
byte *host_basepal;
|
||||
@ -752,6 +754,7 @@ _Host_Frame(float time)
|
||||
}
|
||||
|
||||
host_framecount++;
|
||||
fps_count++;
|
||||
}
|
||||
|
||||
void
|
||||
|
29
NQ/screen.c
29
NQ/screen.c
@ -51,6 +51,7 @@ cvar_t scr_showram = { "showram", "1" };
|
||||
cvar_t scr_showturtle = { "showturtle", "0" };
|
||||
cvar_t scr_showpause = { "showpause", "1" };
|
||||
cvar_t scr_printspeed = { "scr_printspeed", "8" };
|
||||
static cvar_t show_fps = { "show_fps", "0" }; /* set for running times */
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
||||
@ -342,6 +343,7 @@ SCR_Init(void)
|
||||
Cvar_RegisterVariable(&scr_showpause);
|
||||
Cvar_RegisterVariable(&scr_centertime);
|
||||
Cvar_RegisterVariable(&scr_printspeed);
|
||||
Cvar_RegisterVariable(&show_fps);
|
||||
|
||||
Cmd_AddCommand("screenshot", SCR_ScreenShot_f);
|
||||
Cmd_AddCommand("sizeup", SCR_SizeUp_f);
|
||||
@ -416,6 +418,32 @@ SCR_DrawNet(void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SCR_DrawFPS(void)
|
||||
{
|
||||
static double lastframetime;
|
||||
static int lastfps;
|
||||
double t;
|
||||
int x, y;
|
||||
char st[80];
|
||||
|
||||
if (!show_fps.value)
|
||||
return;
|
||||
|
||||
t = Sys_DoubleTime();
|
||||
if ((t - lastframetime) >= 1.0) {
|
||||
lastfps = fps_count;
|
||||
fps_count = 0;
|
||||
lastframetime = t;
|
||||
}
|
||||
|
||||
sprintf(st, "%3d FPS", lastfps);
|
||||
x = vid.width - strlen(st) * 8 - 8;
|
||||
y = vid.height - sb_lines - 8;
|
||||
Draw_String(x, y, st);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
DrawPause
|
||||
@ -906,6 +934,7 @@ SCR_UpdateScreen(void)
|
||||
} else {
|
||||
SCR_DrawRam();
|
||||
SCR_DrawNet();
|
||||
SCR_DrawFPS();
|
||||
SCR_DrawTurtle();
|
||||
SCR_DrawPause();
|
||||
SCR_CheckDrawCenterString();
|
||||
|
@ -474,8 +474,8 @@ void
|
||||
SCR_DrawFPS(void)
|
||||
{
|
||||
static double lastframetime;
|
||||
double t;
|
||||
static int lastfps;
|
||||
double t;
|
||||
int x, y;
|
||||
char st[80];
|
||||
|
||||
@ -492,7 +492,6 @@ SCR_DrawFPS(void)
|
||||
sprintf(st, "%3d FPS", lastfps);
|
||||
x = vid.width - strlen(st) * 8 - 8;
|
||||
y = vid.height - sb_lines - 8;
|
||||
// Draw_TileClear(x, y, strlen(st) * 8, 8);
|
||||
Draw_String(x, y, st);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user