X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_display.c;h=2ba0ec549c9f277bda903501f92ead5580b15cf7;hb=9e756b17d58b2991a8f4735c14d40a5843fc7db7;hp=ca3b15189a2139047e5e173304535a2679ac9a60;hpb=fe89df7de1aa6a732a441e983cce03e1fd6fd81a;p=freeglut diff --git a/src/freeglut_display.c b/src/freeglut_display.c index ca3b151..2ba0ec5 100644 --- a/src/freeglut_display.c +++ b/src/freeglut_display.c @@ -25,16 +25,9 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define G_LOG_DOMAIN "freeglut-display" - -#include "../include/GL/freeglut.h" +#include #include "freeglut_internal.h" - /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* @@ -42,15 +35,14 @@ */ void FGAPIENTRY glutPostRedisplay( void ) { - /* - * Is there a current window set? - */ - freeglut_assert_ready; freeglut_assert_window; - - /* - * Just mark the window as one that we need to redisplay... - */ - fgStructure.Window->State.Redisplay = TRUE; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" ); + if ( ! fgStructure.CurrentWindow ) + { + fgError ( " ERROR: Function <%s> called" + " with no current window defined.", "glutPostRedisplay" ) ; + } + + fgStructure.CurrentWindow->State.Redisplay = GL_TRUE; } /* @@ -58,51 +50,37 @@ void FGAPIENTRY glutPostRedisplay( void ) */ void FGAPIENTRY glutSwapBuffers( void ) { - /* - * As long as we've got a current window set... - */ - freeglut_assert_ready; freeglut_assert_window; - - /* - * Have the mouse cursor drawn for the current window - */ - fgDisplayCursor(); - - /* - * Make sure the current context is flushed - */ - glFlush(); + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" ); + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" ); /* - * If it's single-buffered, we shouldn't be here. + * "glXSwapBuffers" already performs an implicit call to "glFlush". What + * about "SwapBuffers"? */ - if ( ! fgStructure.Window->Window.DoubleBuffered ) return ; - -#if TARGET_HOST_UNIX_X11 - /* - * Issue the glXSwapBuffers call and be done with it - */ - glXSwapBuffers( fgDisplay.Display, fgStructure.Window->Window.Handle ); - -#elif TARGET_HOST_WIN32 - /* - * Swap the window's buffers - */ - SwapBuffers( fgStructure.Window->Window.Device ); - + glFlush( ); + if( ! fgStructure.CurrentWindow->Window.DoubleBuffered ) + return; + +#if TARGET_HOST_POSIX_X11 + glXSwapBuffers( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle ); +#elif TARGET_HOST_MS_WINDOWS + SwapBuffers( fgStructure.CurrentWindow->Window.Device ); #endif /* GLUT_FPS env var support */ - if (fgState.FPSInterval) { - GLint t = glutGet(GLUT_ELAPSED_TIME); + if( fgState.FPSInterval ) + { + GLint t = glutGet( GLUT_ELAPSED_TIME ); fgState.SwapCount++; - if (fgState.SwapTime == 0) + 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); + 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; } @@ -116,22 +94,10 @@ void FGAPIENTRY glutPostWindowRedisplay( int windowID ) { SFG_Window* window; - freeglut_assert_ready; - - /* - * Try looking for the window - */ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" ); window = fgWindowByID( windowID ); - - /* - * If failed, return - */ - freeglut_return_if_fail( window != NULL ); - - /* - * Otherwise mark the window for being redisplayed - */ - window->State.Redisplay = TRUE; + freeglut_return_if_fail( window ); + window->State.Redisplay = GL_TRUE; } /*** END OF FILE ***/