X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_display.c;h=de198415fce2791c47d98365ea99cd0697c270f8;hb=2c52e17121abf4888117ab6b1c94be48ebd569c5;hp=0b1f672b8023b8ca5bbb24d2be51428d301e1a6f;hpb=c90e3f21e02020232054f78029ef9071c7359cfb;p=freeglut diff --git a/freeglut-1.3/freeglut_display.c b/freeglut-1.3/freeglut_display.c index 0b1f672..de19841 100644 --- a/freeglut-1.3/freeglut_display.c +++ b/freeglut-1.3/freeglut_display.c @@ -7,10 +7,6 @@ * Written by Pawel W. Olszta, * Creation date: Fri Dec 3 1999 * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation @@ -36,7 +32,7 @@ #define G_LOG_DOMAIN "freeglut-display" #include "../include/GL/freeglut.h" -#include "../include/GL/freeglut_internal.h" +#include "freeglut_internal.h" /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ @@ -78,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 @@ -91,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; + } + } } /*