X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_display.c;h=de198415fce2791c47d98365ea99cd0697c270f8;hb=2c52e17121abf4888117ab6b1c94be48ebd569c5;hp=7f7e3c12d4fec9d18c8277a7dc520f820845cc5d;hpb=583baa8756a71ed088b8e46c52a945218037314c;p=freeglut diff --git a/freeglut-1.3/freeglut_display.c b/freeglut-1.3/freeglut_display.c index 7f7e3c1..de19841 100644 --- a/freeglut-1.3/freeglut_display.c +++ b/freeglut-1.3/freeglut_display.c @@ -74,12 +74,12 @@ void FGAPIENTRY glutSwapBuffers( void ) */ glFlush(); -#if TARGET_HOST_UNIX_X11 /* * If it's single-buffered, we shouldn't be here. */ if ( ! fgStructure.Window->Window.DoubleBuffered ) return ; +#if TARGET_HOST_UNIX_X11 /* * Issue the glXSwapBuffers call and be done with it */ @@ -92,6 +92,22 @@ void FGAPIENTRY glutSwapBuffers( void ) SwapBuffers( fgStructure.Window->Window.Device ); #endif + + /* GLUT_FPS env var support */ + if (fgState.FPSInterval) { + GLint t = glutGet(GLUT_ELAPSED_TIME); + fgState.SwapCount++; + if (fgState.SwapTime == 0) + fgState.SwapTime = t; + else if (t - fgState.SwapTime > fgState.FPSInterval) { + float time = 0.001f * (t - fgState.SwapTime); + float fps = (float) fgState.SwapCount / time; + fprintf(stderr, "freeglut: %d frames in %.2f seconds = %.2f FPS\n", + fgState.SwapCount, time, fps); + fgState.SwapTime = t; + fgState.SwapCount = 0; + } + } } /*