X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_gamemode.c;h=c1764b8926bf1701f27e99f85f33a4db5f6e6dc4;hb=cb35752f171cdd1ee2319194c890d86bc6242259;hp=0344525f0a21a5f23f832b19d1b5011fa7272472;hpb=65e03872c287ab34ae76bd1831a3786d5e986b72;p=freeglut diff --git a/src/freeglut_gamemode.c b/src/freeglut_gamemode.c index 0344525..c1764b8 100644 --- a/src/freeglut_gamemode.c +++ b/src/freeglut_gamemode.c @@ -48,7 +48,7 @@ * Remembers the current visual settings, so that * we can change them and restore later... */ -void fghRememberState( void ) +static void fghRememberState( void ) { #if TARGET_HOST_UNIX_X11 @@ -86,10 +86,8 @@ void fghRememberState( void ) ); } - /* - * Query the current display settings: - */ - fgDisplay.DisplayModeValid = + /* Query the current display settings: */ + fgDisplay.DisplayModeValid = XF86VidModeGetModeLine( fgDisplay.Display, fgDisplay.Screen, @@ -98,7 +96,7 @@ void fghRememberState( void ) ); if( !fgDisplay.DisplayModeValid ) - fgWarning( "Runtime use of XF86VidModeGetModeLine failed.\n" ); + fgWarning( "Runtime use of XF86VidModeGetModeLine failed." ); # else /* @@ -107,13 +105,11 @@ void fghRememberState( void ) */ # endif -#elif TARGET_HOST_WIN32 +#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE /* DEVMODE devMode; */ - - /* - * Grab the current desktop settings... - */ + + /* Grab the current desktop settings... */ /* hack to get around my stupid cross-gcc headers */ #define FREEGLUT_ENUM_CURRENT_SETTINGS -1 @@ -121,9 +117,7 @@ void fghRememberState( void ) EnumDisplaySettings( NULL, FREEGLUT_ENUM_CURRENT_SETTINGS, &fgDisplay.DisplayMode ); - /* - * Make sure we will be restoring all settings needed - */ + /* Make sure we will be restoring all settings needed */ fgDisplay.DisplayMode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; @@ -133,14 +127,12 @@ void fghRememberState( void ) /* * Restores the previously remembered visual settings */ -void fghRestoreState( void ) +static void fghRestoreState( void ) { #if TARGET_HOST_UNIX_X11 # ifdef X_XF86VidModeGetAllModeLines - /* - * Restore the remembered pointer position: - */ + /* Restore the remembered pointer position: */ XWarpPointer( fgDisplay.Display, None, fgDisplay.RootWindow, 0, 0, 0, 0, fgDisplay.DisplayPointerX, fgDisplay.DisplayPointerY @@ -204,11 +196,9 @@ void fghRestoreState( void ) */ # endif -#elif TARGET_HOST_WIN32 +#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE - /* - * Restore the previously rememebered desktop display settings - */ + /* Restore the previously rememebered desktop display settings */ ChangeDisplaySettings( &fgDisplay.DisplayMode, 0 ); #endif @@ -217,11 +207,9 @@ void fghRestoreState( void ) /* * Checks the display mode settings against user's preferences */ -GLboolean fghCheckDisplayMode( int width, int height, int depth, int refresh ) +static GLboolean fghCheckDisplayMode( int width, int height, int depth, int refresh ) { - /* - * The desired values should be stored in fgState structure... - */ + /* The desired values should be stored in fgState structure... */ return ( width == fgState.GameModeSize.X ) && ( height == fgState.GameModeSize.Y ) && ( depth == fgState.GameModeDepth ) && @@ -231,7 +219,7 @@ GLboolean fghCheckDisplayMode( int width, int height, int depth, int refresh ) /* * Changes the current display mode to match user's settings */ -GLboolean fghChangeDisplayMode( GLboolean haveToTest ) +static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) { #if TARGET_HOST_UNIX_X11 @@ -257,9 +245,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) &displayModes ); - /* - * Check every of the modes looking for one that matches our demands - */ + /* Check every of the modes looking for one that matches our demands */ for( i = 0; i < displayModesCount; i++ ) { if( fghCheckDisplayMode( displayModes[ i ]->hdisplay, @@ -269,9 +255,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) { if( haveToTest ) return GL_TRUE; - /* - * OKi, this is the display mode we have been looking for... - */ + /* OKi, this is the display mode we have been looking for... */ XF86VidModeSwitchToMode( fgDisplay.Display, fgDisplay.Screen, @@ -282,9 +266,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) } } - /* - * Something must have went wrong - */ + /* Something must have gone wrong */ return GL_FALSE; # else @@ -294,7 +276,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) */ # endif -#elif TARGET_HOST_WIN32 +#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE unsigned int displayModes = 0, mode = 0xffffffff; GLboolean success = GL_FALSE; @@ -307,9 +289,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) */ while( EnumDisplaySettings( NULL, displayModes, &devMode ) ) { - /* - * Does the enumerated display mode match the user's preferences? - */ + /* Does the enumerated display mode match the user's preferences? */ if( fghCheckDisplayMode( devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmDisplayFrequency ) ) @@ -325,9 +305,7 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) /* then try without Display Frequency */ displayModes = 0; - /* - * Enumerate the available display modes - */ + /* Enumerate the available display modes */ while( EnumDisplaySettings( NULL, displayModes, &devMode ) ) { /* then try without Display Frequency */ @@ -343,24 +321,18 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) } } - /* - * Did we find a matching display mode? - */ + /* Did we find a matching display mode? */ if( mode != 0xffffffff ) { int retVal = DISP_CHANGE_SUCCESSFUL; - /* - * Mark the values we want to modify in the display change call - */ + /* Mark the values we want to modify in the display change call */ devMode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; retVal = ChangeDisplaySettings( &devMode, haveToTest ? CDS_TEST : 0 ); - /* - * I don't know if it's really needed, but looks nice: - */ + /* I don't know if it's really needed, but looks nice: */ success = (retVal == DISP_CHANGE_SUCCESSFUL) || (retVal == DISP_CHANGE_NOTUPDATED); @@ -407,9 +379,7 @@ void FGAPIENTRY glutGameModeString( const char* string ) string ); - /* - * Hopefully it worked, and if not, we still have the default values - */ + /* Hopefully it worked, and if not, we still have the default values */ fgState.GameModeSize.X = width; fgState.GameModeSize.Y = height; fgState.GameModeDepth = depth; @@ -432,7 +402,7 @@ int FGAPIENTRY glutEnterGameMode( void ) return FALSE; } - fgStructure.GameMode = fgCreateWindow( + fgStructure.GameMode = fgCreateWindow( NULL, "FREEGLUT", 0, 0, fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE ); @@ -453,7 +423,7 @@ int FGAPIENTRY glutEnterGameMode( void ) /* Move the Pointer to the middle of the fullscreen window */ XWarpPointer( fgDisplay.Display, - None, + None, fgDisplay.RootWindow, 0, 0, 0, 0, fgState.GameModeSize.X/2, fgState.GameModeSize.Y/2 @@ -476,7 +446,7 @@ int FGAPIENTRY glutEnterGameMode( void ) GrabModeAsync, GrabModeAsync, fgStructure.GameMode->Window.Handle, None, CurrentTime) ) usleep( 100 ); - + /* * Change input focus to the new window. This will exit the application * if the new window is not viewable yet, see the XGrabPointer loop above. @@ -495,9 +465,7 @@ int FGAPIENTRY glutEnterGameMode( void ) int x, y; Window child; - /* - * Change to viewport to the window topleft edge: - */ + /* Change to viewport to the window topleft edge: */ XF86VidModeSetViewPort( fgDisplay.Display, fgDisplay.Screen, 0, 0 ); /* @@ -522,9 +490,7 @@ int FGAPIENTRY glutEnterGameMode( void ) #endif - /* - * Grab the keyboard, too - */ + /* Grab the keyboard, too */ XGrabKeyboard( fgDisplay.Display, fgStructure.GameMode->Window.Handle, @@ -549,6 +515,8 @@ void FGAPIENTRY glutLeaveGameMode( void ) fgAddToWindowDestroyList( fgStructure.GameMode ); + fgStructure.GameMode = NULL; + #if TARGET_HOST_UNIX_X11 XUngrabPointer( fgDisplay.Display, CurrentTime ); @@ -591,6 +559,7 @@ int FGAPIENTRY glutGameModeGet( GLenum eWhat ) return !!fgStructure.GameMode; } + fgWarning( "Unknown gamemode get: %d", eWhat ); return -1; }