skeleton glut app has low frame rate (code)

I’m just swapping buffers here and getting only 76 frames per second. Can that be right? In order to maintain 60fps I would need to spend 4/5ths of the time on each frame just swapping the buffer. This is on a GeForce4 TS 2ghz AMD.

#include <gl\glut.h>
#include <stdio.h>

int ticks = 0;

void countFPS(int t)
	printf("FPS: %d
", ticks);
	ticks = 0;
	glutTimerFunc( 1000, countFPS, 0);

void renderScene(void) //**RENDERSCENE**//


int main(int argc, char **argv)
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	glutCreateWindow("frame rate test");


	glutTimerFunc( 1000, countFPS, 0);


do you have vsync enabled?

You can disable it within your app with the WGL extension wglSwapInterval(0).

I just recomplied with GL_SINGLE and now I get over 340,000 FPS. Could vsync be screwing up double buffering and not single? My desktop refresh is 60hz, so I thought vsync couldn’t be an issue.

With a single buffer, there is no buffer to swap.

You can also disable the vsync from your desktop settings dialog. Try that and see what happens…

I forgot to say I was calling glFlush with the single buffer.

But you’re right, its vsync. This app runs at 1500fps after disabling vsync in the nvidia control panel.

I’m not sure what to do now. I’m rendering a heightmap with texture blending and I get an extra 10 to 15 FPS with vsync turned off. Do all games turn vsync off then?

glFlush empties the command buffers, while glFinish blocks until all commands complete. Neither of these calls have anything to do with vsync or frame buffer swapping. With vsync enabled in a double buffer configuration, SwapBuffers() waits for the next vertical retrace to swap the front and back frame buffers. In a single buffer scenario, there is only the front buffer, hence no swap is possible and vsync becomes irrelevant.

Do all games turn vsync off? Don’t know. Some do. Obviously you’d like to leave it on for the visual quality, but I think some games make it an option, so gamers can turn it off for the extra fps, especially on older systems that are struggling with the newer games…

Thanks Hlz, I’ll get the WGL extension. That will be fine for what I’m doing for awhile.