X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_main.c;h=66281ea71812108a55b42aa5fa0f0a7f2648e8c6;hb=0cd6817079c9f545bbff65d6ac86d9fac6b92db9;hp=b1654a5275f43cff3e9edf7db05bcfaff668fb22;hpb=1114cde95ebfcfedf5969b0484a0c94b8f79cb14;p=freeglut diff --git a/src/Common/freeglut_main.c b/src/Common/freeglut_main.c index b1654a5..66281ea 100644 --- a/src/Common/freeglut_main.c +++ b/src/Common/freeglut_main.c @@ -72,6 +72,7 @@ struct GXKeyList gxKeyList; extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ); extern void fgPlatformDisplayWindow ( SFG_Window *window ); +extern unsigned long fgPlatformSystemTime ( void ); extern void fgPlatformSleepForEvents( long msec ); extern void fgPlatformProcessSingleEvent ( void ); extern void fgPlatformMainLoopPreliminaryWork ( void ); @@ -96,11 +97,11 @@ extern void fgPlatformMainLoopPreliminaryWork ( void ); * match the new window size. */ #if TARGET_HOST_POSIX_X11 -static void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) +void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) { - XResizeWindow( fgDisplay.Display, window->Window.Handle, + XResizeWindow( fgDisplay.pDisplay.Display, window->Window.Handle, width, height ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } #endif @@ -170,10 +171,20 @@ void fghRedrawWindow ( SFG_Window *window ) * A static helper function to execute display callback for a window */ #if TARGET_HOST_POSIX_X11 -static void fgPlatformDisplayWindow ( SFG_Window *window ) +void fgPlatformDisplayWindow ( SFG_Window *window ) { fghRedrawWindow ( window ) ; } + + +unsigned long fgPlatformSystemTime ( void ) +{ +#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY + struct timeval now; + gettimeofday( &now, NULL ); + return now.tv_usec/1000 + now.tv_sec*1000; +#endif +} #endif static void fghcbDisplayWindow( SFG_Window *window, @@ -262,18 +273,9 @@ static void fghCheckTimers( void ) * when subtracting an initial start time, unless the total time exceeds * 32-bit, where the GLUT API return value is also overflowed. */ -unsigned long fgSystemTime(void) { -#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY - struct timeval now; - gettimeofday( &now, NULL ); - return now.tv_usec/1000 + now.tv_sec*1000; -#elif TARGET_HOST_MS_WINDOWS -# if defined(_WIN32_WCE) - return GetTickCount(); -# else - return timeGetTime(); -# endif -#endif +unsigned long fgSystemTime(void) +{ + return fgPlatformSystemTime (); } /* @@ -416,7 +418,7 @@ static long fghNextTimer( void ) */ #if TARGET_HOST_POSIX_X11 -static void fgPlatformSleepForEvents( long msec ) +void fgPlatformSleepForEvents( long msec ) { /* * Possibly due to aggressive use of XFlush() and friends, @@ -427,14 +429,14 @@ static void fgPlatformSleepForEvents( long msec ) * need to allow that we may have an empty socket but non- * empty event queue. */ - if( ! XPending( fgDisplay.Display ) ) + if( ! XPending( fgDisplay.pDisplay.Display ) ) { fd_set fdset; int err; int socket; struct timeval wait; - socket = ConnectionNumber( fgDisplay.Display ); + socket = ConnectionNumber( fgDisplay.pDisplay.Display ); FD_ZERO( &fdset ); FD_SET( socket, &fdset ); wait.tv_sec = msec / 1000; @@ -943,9 +945,9 @@ void fgPlatformProcessSingleEvent ( void ) FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" ); - while( XPending( fgDisplay.Display ) ) + while( XPending( fgDisplay.pDisplay.Display ) ) { - XNextEvent( fgDisplay.Display, &event ); + XNextEvent( fgDisplay.pDisplay.Display, &event ); #if _DEBUG fghPrintEvent( &event ); #endif @@ -958,7 +960,7 @@ void fgPlatformProcessSingleEvent ( void ) break; } /* Destroy the window when the WM_DELETE_WINDOW message arrives */ - if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow ) + if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.pDisplay.DeleteWindow ) { GETWINDOW( xclient ); @@ -999,13 +1001,13 @@ void fgPlatformProcessSingleEvent ( void ) height = event.xconfigure.height; } - if( ( width != window->State.OldWidth ) || - ( height != window->State.OldHeight ) ) + if( ( width != window->State.pWState.OldWidth ) || + ( height != window->State.pWState.OldHeight ) ) { SFG_Window *current_window = fgStructure.CurrentWindow; - window->State.OldWidth = width; - window->State.OldHeight = height; + window->State.pWState.OldWidth = width; + window->State.pWState.OldHeight = height; if( FETCH_WCB( *window, Reshape ) ) INVOKE_WCB( *window, Reshape, ( width, height ) ); else @@ -1256,7 +1258,7 @@ void fgPlatformProcessSingleEvent ( void ) */ char keys[32]; - XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */ + XQueryKeymap( fgDisplay.pDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */ if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */ { @@ -1405,7 +1407,7 @@ void fgPlatformProcessSingleEvent ( void ) } -static void fgPlatformMainLoopPreliminaryWork ( void ) +void fgPlatformMainLoopPreliminaryWork ( void ) { } #endif