Tutorial *119*
Frames Per Second Display Hi all

If you're like me, you like to test your system with games to see how fast it's running. In Quake3Arena John Carmack kindly gave us a display in the top right hand corner to count the Frames Per Second the system was running at.

With a little help from some code I found in the SourceForge implementation of the engine, and a bit of hacking, I present to you a FPS counter display for Quake.


In gl_screen.c

add above SCR_DrawPause


//muff - hacked out of SourceForge implementation + modified





void SCR_DrawFPS (void)


	extern cvar_t show_fps;

	static double lastframetime;

	double t;

	extern int fps_count;

	static int lastfps;

	int x, y;

	char st[80];

	if (!show_fps.value)


	t = Sys_FloatTime ();

	if ((t - lastframetime) >= 1.0) {

		lastfps = fps_count;

		fps_count = 0;

		lastframetime = t;


	sprintf(st, "%3d FPS", lastfps);

	x = vid.width - strlen(st) * 16 - 16;

	y = 0 ; //vid.height - (sb_lines * (vid.height/240) )- 16;

//	Draw_TileClear(x, y, strlen(st)*16, 16);

	Draw_String(x, y, st);


in host.c

near the top add

cvar_t	show_fps = {"show_fps","0"};	// set for running times - muff

int			fps_count;

lower down, in the Host_InitLocal procedure


	Cvar_RegisterVariable (&show_fps); // muff

at the end of the _Host_Frame routine


	//frame speed counter


and finally we need to call the function

in gl_screen.c in the SCR_UpdateScreen after

		SCR_DrawTurtle ();


		//muff - to show FPS on screen

		SCR_DrawFPS ();

and compile.

To enable the FPS display, in the console type in

     show_fps 1


[email protected]

Not logged in
Sign up