Making the \"key repeat\" initialization consistent with the rest of its usage; also...
[freeglut] / src / freeglut_init.c
index 799c86c..078192c 100644 (file)
@@ -60,7 +60,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE },  /* Position */
                       GL_FALSE,              /* UseCurrentContext */
                       GL_FALSE,              /* GLDebugSwitch */
                       GL_FALSE,              /* XSyncSwitch */
-                      GL_TRUE,               /* KeyRepeat */
+                      GLUT_KEY_REPEAT_ON,    /* KeyRepeat */
                       0xffffffff,            /* Modifiers */
                       0,                     /* FPSInterval */
                       0,                     /* SwapCount */
@@ -196,6 +196,9 @@ static void fghInitialize( const char* displayName )
         ReleaseDC( desktop, context );
     }
 
+    /* Set the timer granularity to 1 ms */
+    timeBeginPeriod ( 1 );
+
 #endif
 
     fgState.Initialised = GL_TRUE;
@@ -262,7 +265,7 @@ void fgDeinitialize( void )
     fgState.ActionOnWindowClose = GLUT_ACTION_EXIT;
     fgState.ExecState           = GLUT_EXEC_STATE_INIT;
 
-    fgState.KeyRepeat       = GL_TRUE;
+    fgState.KeyRepeat       = GLUT_KEY_REPEAT_ON;
     fgState.Modifiers       = 0xffffffff;
 
     fgState.GameModeSize.X  = 640;
@@ -289,7 +292,6 @@ void fgDeinitialize( void )
         fgState.ProgramName = NULL;
     }
 
-
 #if TARGET_HOST_UNIX_X11
 
     /*
@@ -304,6 +306,11 @@ void fgDeinitialize( void )
      */
     XCloseDisplay( fgDisplay.Display );
 
+#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
+
+    /* Reset the timer granularity */
+    timeEndPeriod ( 1 );
+
 #endif
 
     fgState.Initialised = GL_FALSE;
@@ -678,7 +685,6 @@ void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode )
 
 /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
 
-#define NUM_TOKENS             36
 static char* Tokens[] =
 {
     "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double",
@@ -689,18 +695,7 @@ static char* Tokens[] =
     "xstaticgrey", "xgreyscale", "xstaticcolour", "xpseudocolour",
     "xtruecolour", "xdirectcolour", "borderless", "aux"
 };
-
-/* XXX why the heck do we use this table instead of strlen(Tokens[i])? */
-static int TokenLengths[] =
-{
-    5,       4,      3,     4,      6,        10,           5,       6,
-    5,       5,       3,     3,     4,      3,     9,           7,
-    6,        6,        7,         4,      8,          8,          7,
-    11,            10,           12,             12,
-    10,           12,
-    11,            10,           13,             13,
-    11,            13,              10,          3
-};
+#define NUM_TOKENS             (sizeof(Tokens) / sizeof(*Tokens))
 
 void FGAPIENTRY glutInitDisplayString( const char* displayMode )
 {
@@ -722,7 +717,7 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode )
         int i ;
         for ( i = 0; i < NUM_TOKENS; i++ )
         {
-            if ( strncmp ( token, Tokens[i], TokenLengths[i] ) == 0 ) break ;
+            if ( strcmp ( token, Tokens[i] ) == 0 ) break ;
         }
 
         switch ( i )