-\r
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */\r
-\r
-/* This program is freely distributable without licensing fees\r
- and is provided without guarantee or warrantee expressed or\r
- implied. This program is -not- in the public domain. */\r
-\r
-#include <stdio.h>\r
-#include "glutint.h"\r
-\r
-GLint __glutFPS = 0;\r
-GLint __glutSwapCount = 0;\r
-GLint __glutSwapTime = 0;\r
-\r
-/* CENTRY */\r
-void GLUTAPIENTRY\r
-glutSwapBuffers(void)\r
-{\r
- GLUTwindow *window = __glutCurrentWindow;\r
-\r
- if (window->renderWin == window->win) {\r
- if (__glutCurrentWindow->treatAsSingle) {\r
- /* Pretend the double buffered window is single buffered,\r
- so treat glutSwapBuffers as a no-op. */\r
- return;\r
- }\r
- } else {\r
- if (__glutCurrentWindow->overlay->treatAsSingle) {\r
- /* Pretend the double buffered overlay is single\r
- buffered, so treat glutSwapBuffers as a no-op. */\r
- return;\r
- }\r
- }\r
-\r
- /* For the MESA_SWAP_HACK. */\r
- window->usedSwapBuffers = 1;\r
-\r
- SWAP_BUFFERS_LAYER(__glutCurrentWindow);\r
-\r
- /* I considered putting the window being swapped on the\r
- GLUT_FINISH_WORK work list because you could call\r
- glutSwapBuffers from an idle callback which doesn't call\r
- __glutSetWindow which normally adds indirect rendering\r
- windows to the GLUT_FINISH_WORK work list. Not being put\r
- on the list could lead to the buffering up of multiple\r
- redisplays and buffer swaps and hamper interactivity. I\r
- consider this an application bug due to not using\r
- glutPostRedisplay to trigger redraws. If\r
- glutPostRedisplay were used, __glutSetWindow would be\r
- called and a glFinish to throttle buffering would occur. */\r
-\r
- if (__glutFPS) {\r
- GLint t = glutGet(GLUT_ELAPSED_TIME);\r
- __glutSwapCount++;\r
- if (__glutSwapTime == 0)\r
- __glutSwapTime = t;\r
- else if (t - __glutSwapTime > __glutFPS) {\r
- float time = 0.001 * (t - __glutSwapTime);\r
- float fps = (float) __glutSwapCount / time;\r
- fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n",\r
- __glutSwapCount, time, fps);\r
- __glutSwapTime = t;\r
- __glutSwapCount = 0;\r
- }\r
- }\r
-}\r
-/* ENDCENTRY */\r
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+#include <stdio.h>
+#include "glutint.h"
+
+GLint __glutFPS = 0;
+GLint __glutSwapCount = 0;
+GLint __glutSwapTime = 0;
+
+/* CENTRY */
+void GLUTAPIENTRY
+glutSwapBuffers(void)
+{
+ GLUTwindow *window = __glutCurrentWindow;
+
+ if (window->renderWin == window->win) {
+ if (__glutCurrentWindow->treatAsSingle) {
+ /* Pretend the double buffered window is single buffered,
+ so treat glutSwapBuffers as a no-op. */
+ return;
+ }
+ } else {
+ if (__glutCurrentWindow->overlay->treatAsSingle) {
+ /* Pretend the double buffered overlay is single
+ buffered, so treat glutSwapBuffers as a no-op. */
+ return;
+ }
+ }
+
+ /* For the MESA_SWAP_HACK. */
+ window->usedSwapBuffers = 1;
+
+ SWAP_BUFFERS_LAYER(__glutCurrentWindow);
+
+ /* I considered putting the window being swapped on the
+ GLUT_FINISH_WORK work list because you could call
+ glutSwapBuffers from an idle callback which doesn't call
+ __glutSetWindow which normally adds indirect rendering
+ windows to the GLUT_FINISH_WORK work list. Not being put
+ on the list could lead to the buffering up of multiple
+ redisplays and buffer swaps and hamper interactivity. I
+ consider this an application bug due to not using
+ glutPostRedisplay to trigger redraws. If
+ glutPostRedisplay were used, __glutSetWindow would be
+ called and a glFinish to throttle buffering would occur. */
+
+ if (__glutFPS) {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ __glutSwapCount++;
+ if (__glutSwapTime == 0)
+ __glutSwapTime = t;
+ else if (t - __glutSwapTime > __glutFPS) {
+ float time = 0.001 * (t - __glutSwapTime);
+ float fps = (float) __glutSwapCount / time;
+ fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n",
+ __glutSwapCount, time, fps);
+ __glutSwapTime = t;
+ __glutSwapCount = 0;
+ }
+ }
+}
+/* ENDCENTRY */