+ /* If we don't have a valid modeline in the display structure, which
+ * can happen if this is called from glutGameModeGet instead of
+ * glutEnterGameMode, then we need to query the current mode, to make
+ * unspecified settings to default to their current values.
+ */
+ if(!fgDisplay.DisplayModeValid) {
+ if(!XF86VidModeGetModeLine(fgDisplay.Display, fgDisplay.Screen,
+ &fgDisplay.DisplayModeClock, &fgDisplay.DisplayMode)) {
+ return success;
+ }
+ }
+
+ if (fgState.GameModeSize.X == -1)
+ {
+ fgState.GameModeSize.X = fgDisplay.DisplayMode.hdisplay;
+ }
+ if (fgState.GameModeSize.Y == -1)
+ {
+ fgState.GameModeSize.Y = fgDisplay.DisplayMode.vdisplay;
+ }
+ if (fgState.GameModeDepth == -1)
+ {
+ /* can't get color depth from this, nor can we change it, do nothing
+ * TODO: get with XGetVisualInfo()? but then how to set?
+ */
+ }
+ if (fgState.GameModeRefresh == -1)
+ {
+ /* Compute the displays refresh rate, dotclock comes in kHz. */
+ int refresh = ( fgDisplay.DisplayModeClock * 1000 ) /
+ ( fgDisplay.DisplayMode.htotal * fgDisplay.DisplayMode.vtotal );
+
+ fgState.GameModeRefresh = refresh;
+ }
+
+ /* query all possible display modes */