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
31 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
\r
34 * Marks the current window to have the redisplay performed when possible...
\r
36 void FGAPIENTRY glutPostRedisplay( void )
\r
38 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
\r
39 if ( ! fgStructure.CurrentWindow )
\r
41 fgError ( " ERROR: Function <%s> called"
\r
42 " with no current window defined.", "glutPostRedisplay" ) ;
\r
45 fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
\r
49 * Swaps the buffers for the current window (if any)
\r
51 void FGAPIENTRY glutSwapBuffers( void )
\r
53 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
\r
54 FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
\r
57 * "glXSwapBuffers" already performs an implicit call to "glFlush". What
\r
58 * about "SwapBuffers"?
\r
61 if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
\r
64 #if TARGET_HOST_POSIX_X11
\r
65 glXSwapBuffers( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
\r
66 #elif TARGET_HOST_MS_WINDOWS
\r
67 SwapBuffers( fgStructure.CurrentWindow->Window.Device );
\r
70 /* GLUT_FPS env var support */
\r
71 if( fgState.FPSInterval )
\r
73 GLint t = glutGet( GLUT_ELAPSED_TIME );
\r
74 fgState.SwapCount++;
\r
75 if( fgState.SwapTime == 0 )
\r
76 fgState.SwapTime = t;
\r
77 else if( t - fgState.SwapTime > fgState.FPSInterval )
\r
79 float time = 0.001f * ( t - fgState.SwapTime );
\r
80 float fps = ( float )fgState.SwapCount / time;
\r
82 "freeglut: %d frames in %.2f seconds = %.2f FPS\n",
\r
83 fgState.SwapCount, time, fps );
\r
84 fgState.SwapTime = t;
\r
85 fgState.SwapCount = 0;
\r
91 * Mark appropriate window to be displayed
\r
93 void FGAPIENTRY glutPostWindowRedisplay( int windowID )
\r
97 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
\r
98 window = fgWindowByID( windowID );
\r
99 freeglut_return_if_fail( window );
\r
100 window->State.Redisplay = GL_TRUE;
\r
103 /*** END OF FILE ***/
\r