fps counter works on CRTs and not LCDs

How strange, my FPS counter works on certain kinds of monitors?

The bug is that on LCDs, it reports VERY high framerates at times, like, over 200. And on CRTs, it works perfectly, for example, if I set the monitor to 75 hertz, it reports no more than 75, if I set it to 90, it reports no more than 90, etc. The function(below) is called right before glutSwapBuffers().

The only explanation that I can think of is that the glutDisplayFunc is getting called multiple times before the buffer is actually swapped…or something…any ideas?

Of course, here is the function:

void fps(void)
static unsigned old_time = 0;
static unsigned new_time = 0;
unsigned delta_time;
static int frames = 0;

static char buffer[BUFSIZ];


if(old_time == 0)
	old_time = time(NULL);
new_time = time(NULL);
delta_time = new_time - old_time;
if(delta_time >= 1)
	old_time = new_time;

	sprintf(buffer, "fps:  %d", frames);
	frames = 0;
	glPrint(1100, 1000, 0, 1, 1, }

Sorry if the formatting got too messed up when I pasted it from vcpp.

Hi !

I guess it has something to do with the fact that an lcd does not need to wait for the electron beam so it does not have any real refresh rate (or do they ?), just a wild guess.

I am not sure how the video update is done on lcd’s.


Try setting the buffer swap interval to another value.

You can find the swap control specifications at:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt (windows)
http://oss.sgi.com/projects/ogl-sample/registry/SGI/swap_control.txt (linux)

Maybe that will help.