* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <GL/freeglut.h>
#include "freeglut_internal.h"
GL_FALSE, /* UseCurrentContext */
GL_FALSE, /* GLDebugSwitch */
GL_FALSE, /* XSyncSwitch */
- GL_TRUE, /* KeyRepeat */
- 0xffffffff, /* Modifiers */
+ GLUT_KEY_REPEAT_ON, /* KeyRepeat */
+ INVALID_MODIFIERS, /* Modifiers */
0, /* FPSInterval */
0, /* SwapCount */
0, /* SwapTime */
GLUT_ACTION_EXIT, /* ActionOnWindowClose */
GLUT_EXEC_STATE_INIT, /* ExecState */
NULL, /* ProgramName */
- GL_FALSE /* JoysticksInitialised */
+ GL_FALSE, /* JoysticksInitialised */
+ GL_FALSE /* InputDevsInitialised */
};
/* Register the window class */
atom = RegisterClass( &wc );
- assert( atom );
+ FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" );
}
/* The screen dimensions can be obtained via GetSystemMetrics() calls */
ReleaseDC( desktop, context );
}
+ /* Set the timer granularity to 1 ms */
+ timeBeginPeriod ( 1 );
+
#endif
fgState.Initialised = GL_TRUE;
+
+ /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
+ fgInitialiseInputDevices();
}
/*
return;
}
- /* fgState.Initialised = GL_FALSE; */
-
/* If there was a menu created, destroy the rendering context */
if( fgStructure.MenuContext )
{
+#if TARGET_HOST_UNIX_X11
+ /* Note that the MVisualInfo is not owned by the MenuContext! */
+ glXDestroyContext( fgDisplay.Display, fgStructure.MenuContext->MContext );
+#endif
free( fgStructure.MenuContext );
fgStructure.MenuContext = NULL;
}
fgDestroyStructure( );
- while( ( timer = fgState.Timers.First ) )
+ while( ( timer = fgState.Timers.First) )
{
fgListRemove( &fgState.Timers, &timer->Node );
free( timer );
#if !TARGET_HOST_WINCE
if ( fgState.JoysticksInitialised )
fgJoystickClose( );
+
+ if ( fgState.InputDevsInitialised )
+ fgInputDeviceClose( );
#endif /* !TARGET_HOST_WINCE */
fgState.JoysticksInitialised = GL_FALSE;
+ fgState.InputDevsInitialised = GL_FALSE;
fgState.Initialised = GL_FALSE;
fgState.ActionOnWindowClose = GLUT_ACTION_EXIT;
fgState.ExecState = GLUT_EXEC_STATE_INIT;
- fgState.KeyRepeat = GL_TRUE;
- fgState.Modifiers = 0xffffffff;
+ fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
+ fgState.Modifiers = INVALID_MODIFIERS;
fgState.GameModeSize.X = 640;
fgState.GameModeSize.Y = 480;
fgState.ProgramName = NULL;
}
-
#if TARGET_HOST_UNIX_X11
/*
*/
XCloseDisplay( fgDisplay.Display );
+#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
+
+ /* Reset the timer granularity */
+ timeEndPeriod ( 1 );
+
#endif
+
+ fgState.Initialised = GL_FALSE;
}
/*
* size.
*/
- if( geometry )
+ if (geometry )
{
unsigned int parsedWidth, parsedHeight;
int mask = XParseGeometry( geometry,
/* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
-#define NUM_TOKENS 36
static char* Tokens[] =
{
"alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double",
"xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
"xtruecolor", "xdirectcolor",
"xstaticgrey", "xgreyscale", "xstaticcolour", "xpseudocolour",
- "xtruecolour", "xdirectcolour", "borderless"
-};
-
-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
+ "xtruecolour", "xdirectcolour", "borderless", "aux"
};
+#define NUM_TOKENS (sizeof(Tokens) / sizeof(*Tokens))
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 )
#endif
break ;
- case 36 : /* Unrecognized */
+ case 36 : /* "aux": some number of aux buffers */
+ glut_state_flag |= GLUT_AUX1;
+ break ;
+
+ case 37 : /* Unrecognized */
fgWarning ( "WARNING - Display string token not recognized: %s",
token );
break ;