4 * Display message posting, context buffer swapping.
\r
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
\r
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
\r
8 * Creation date: Fri Dec 3 1999
\r
10 * Permission is hereby granted, free of charge, to any person obtaining a
\r
11 * copy of this software and associated documentation files (the "Software"),
\r
12 * to deal in the Software without restriction, including without limitation
\r
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
\r
14 * and/or sell copies of the Software, and to permit persons to whom the
\r
15 * Software is furnished to do so, subject to the following conditions:
\r
17 * The above copyright notice and this permission notice shall be included
\r
18 * in all copies or substantial portions of the Software.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
\r
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
\r
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
28 #include <GL/freeglut.h>
\r
29 #include "freeglut_internal.h"
\r
32 /* Function prototypes */
\r
33 extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );
\r
36 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
\r
39 * Marks the current window to have the redisplay performed when possible...
\r
41 void FGAPIENTRY glutPostRedisplay( void )
\r
43 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
\r
44 if ( ! fgStructure.CurrentWindow )
\r
46 fgError ( " ERROR: Function <%s> called"
\r
47 " with no current window defined.", "glutPostRedisplay" ) ;
\r
50 fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
\r
54 * Swaps the buffers for the current window (if any)
\r
56 void FGAPIENTRY glutSwapBuffers( void )
\r
58 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
\r
59 FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
\r
62 * "glXSwapBuffers" already performs an implicit call to "glFlush". What
\r
63 * about "SwapBuffers"?
\r
66 if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
\r
69 fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );
\r
71 /* GLUT_FPS env var support */
\r
72 if( fgState.FPSInterval )
\r
74 GLint t = glutGet( GLUT_ELAPSED_TIME );
\r
75 fgState.SwapCount++;
\r
76 if( fgState.SwapTime == 0 )
\r
77 fgState.SwapTime = t;
\r
78 else if( t - fgState.SwapTime > fgState.FPSInterval )
\r
80 float time = 0.001f * ( t - fgState.SwapTime );
\r
81 float fps = ( float )fgState.SwapCount / time;
\r
83 "freeglut: %d frames in %.2f seconds = %.2f FPS\n",
\r
84 fgState.SwapCount, time, fps );
\r
85 fgState.SwapTime = t;
\r
86 fgState.SwapCount = 0;
\r
92 * Mark appropriate window to be displayed
\r
94 void FGAPIENTRY glutPostWindowRedisplay( int windowID )
\r
98 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
\r
99 window = fgWindowByID( windowID );
\r
100 freeglut_return_if_fail( window );
\r
101 window->State.Redisplay = GL_TRUE;
\r
104 /*** END OF FILE ***/
\r