X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_display.c;h=d6ce1cb76d9797873e45bf08b504014618f47787;hb=9d66916bab11e22ff2b670638be3a50e604897a1;hp=9117a10952197bc7dd3d848ca2585afd163a6427;hpb=8fca860c3dd3f20027fc730c386047166c3b9ee7;p=freeglut diff --git a/freeglut-1.3/freeglut_display.c b/freeglut-1.3/freeglut_display.c index 9117a10..d6ce1cb 100644 --- a/freeglut-1.3/freeglut_display.c +++ b/freeglut-1.3/freeglut_display.c @@ -74,6 +74,11 @@ void FGAPIENTRY glutSwapBuffers( void ) */ glFlush(); + /* + * 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 @@ -87,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.001 * (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; + } + } } /*