Made Modifers variable global as per glut classic.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@357 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
b47a8b1fcc
commit
a437c328e9
@ -66,6 +66,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
||||
GL_FALSE, /* GLDebugSwitch */
|
||||
GL_FALSE, /* XSyncSwitch */
|
||||
GL_TRUE, /* IgnoreKeyRepeat */
|
||||
0xffffffff, /* Modifiers */
|
||||
0, /* FPSInterval */
|
||||
0, /* SwapCount */
|
||||
0, /* SwapTime */
|
||||
@ -84,6 +85,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
||||
72, /* GameModeRefresh */
|
||||
GLUT_ACTION_EXIT, /* ActionOnWindowClose */
|
||||
GLUT_EXEC_STATE_INIT /* ExecState */
|
||||
NULL, /* ProgramName */
|
||||
};
|
||||
|
||||
|
||||
@ -258,6 +260,7 @@ void fgDeinitialize( void )
|
||||
fgState.ExecState = GLUT_EXEC_STATE_INIT;
|
||||
|
||||
fgState.IgnoreKeyRepeat = GL_TRUE;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
|
||||
fgState.GameModeSize.X = 640;
|
||||
fgState.GameModeSize.Y = 480;
|
||||
@ -453,16 +456,17 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
||||
char* geometry = NULL;
|
||||
int i, j, argc = *pargc;
|
||||
|
||||
if (pargc && *pargc && argv && *argv && **argv)
|
||||
fgState.ProgramName = strdup (*argv);
|
||||
else
|
||||
fgState.ProgramName = strdup ("");
|
||||
if( !fgState.ProgramName )
|
||||
fgError ("Could not allocate space for the program's name.");
|
||||
|
||||
if( fgState.Initalized )
|
||||
fgError( "illegal glutInit() reinitialization attemp" );
|
||||
|
||||
if (pargc && *pargc && argv && *argv && **argv)
|
||||
{
|
||||
fgState.ProgramName = strdup (*argv);
|
||||
|
||||
if( !fgState.ProgramName )
|
||||
fgError ("Could not allocate space for the program's name.");
|
||||
}
|
||||
|
||||
fgCreateStructure( );
|
||||
|
||||
fgElapsedTime( );
|
||||
|
@ -230,6 +230,7 @@ struct tagSFG_State
|
||||
GLboolean XSyncSwitch; /* X11 sync protocol switch */
|
||||
|
||||
GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat. */
|
||||
int Modifiers; /* Current ALT/SHIFT/CTRL state */
|
||||
|
||||
GLuint FPSInterval; /* Interval between FPS printfs */
|
||||
GLuint SwapCount; /* Count of glutSwapBuffer calls */
|
||||
@ -342,7 +343,6 @@ struct tagSFG_WindowState
|
||||
GLboolean Visible; /* Is the window visible now */
|
||||
|
||||
int Cursor; /* The currently selected cursor */
|
||||
int Modifiers; /* The current ALT/SHIFT/CTRL state */
|
||||
|
||||
long JoystickPollRate; /* The joystick polling rate */
|
||||
long JoystickLastPoll; /* When the last poll has happened */
|
||||
|
@ -796,7 +796,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
/*
|
||||
* XXX Why don't we use {window}? Other code here does...
|
||||
*/
|
||||
fgStructure.Window->State.Modifiers = fgGetXModifiers( &event );
|
||||
fgState.Modifiers = fgGetXModifiers( &event );
|
||||
|
||||
/*
|
||||
* Finally execute the mouse or mouse wheel callback
|
||||
@ -839,7 +839,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
/*
|
||||
* Trash the modifiers state
|
||||
*/
|
||||
fgStructure.Window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -891,11 +891,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
if( keyboard_cb )
|
||||
{
|
||||
fgSetWindow( window );
|
||||
window->State.Modifiers = fgGetXModifiers( &event );
|
||||
fgState.Modifiers = fgGetXModifiers( &event );
|
||||
keyboard_cb( asciiCode[ 0 ],
|
||||
event.xkey.x, event.xkey.y
|
||||
);
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -945,9 +945,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
if( special_cb && ( special != -1 ) )
|
||||
{
|
||||
fgSetWindow( window );
|
||||
window->State.Modifiers = fgGetXModifiers( &event );
|
||||
fgState.Modifiers = fgGetXModifiers( &event );
|
||||
special_cb( special, event.xkey.x, event.xkey.y );
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1286,7 +1286,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
}
|
||||
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
if( ( wParam & MK_LBUTTON ) ||
|
||||
( wParam & MK_MBUTTON ) ||
|
||||
@ -1297,7 +1297,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
INVOKE_WCB( *window, Passive, ( window->State.MouseX,
|
||||
window->State.MouseY ) );
|
||||
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1423,7 +1423,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
|
||||
fgSetWindow( window );
|
||||
fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
INVOKE_WCB(
|
||||
*window, Mouse,
|
||||
@ -1434,7 +1434,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
)
|
||||
);
|
||||
|
||||
fgStructure.Window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1468,7 +1468,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
|
||||
fgSetWindow( window );
|
||||
fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
while( ticks-- )
|
||||
if( FETCH_WCB( *window, MouseWheel ) )
|
||||
@ -1498,7 +1498,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
);
|
||||
}
|
||||
|
||||
fgStructure.Window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1515,7 +1515,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
* Remember the current modifiers state. This is done here in order
|
||||
* to make sure the VK_DELETE keyboard callback is executed properly.
|
||||
*/
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
GetCursorPos( &mouse_pos );
|
||||
ScreenToClient( window->Window.Handle, &mouse_pos );
|
||||
@ -1567,7 +1567,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
window->State.MouseX, window->State.MouseY )
|
||||
);
|
||||
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1581,7 +1581,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
* Remember the current modifiers state. This is done here in order
|
||||
* to make sure the VK_DELETE keyboard callback is executed properly.
|
||||
*/
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
GetCursorPos( &mouse_pos );
|
||||
ScreenToClient( window->Window.Handle, &mouse_pos );
|
||||
@ -1650,7 +1650,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
window->State.MouseX, window->State.MouseY )
|
||||
);
|
||||
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1668,12 +1668,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
*/
|
||||
if( FETCH_WCB( *window, Keyboard ) )
|
||||
{
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
fgState.Modifiers = fgGetWin32Modifiers( );
|
||||
INVOKE_WCB( *window, Keyboard,
|
||||
( (char)wParam,
|
||||
window->State.MouseX, window->State.MouseY )
|
||||
);
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
fgState.Modifiers = 0xffffffff;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -562,16 +562,13 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
*/
|
||||
int FGAPIENTRY glutGetModifiers( void )
|
||||
{
|
||||
if( fgStructure.Window == NULL )
|
||||
return( 0 );
|
||||
|
||||
if( fgStructure.Window->State.Modifiers == 0xffffffff )
|
||||
if( fgState.Modifiers == 0xffffffff )
|
||||
{
|
||||
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
return( fgStructure.Window->State.Modifiers );
|
||||
return( fgState.Modifiers );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -105,7 +105,6 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
|
||||
* Set the default mouse cursor and reset the modifiers value
|
||||
*/
|
||||
window->State.Cursor = GLUT_CURSOR_INHERIT;
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
|
||||
window->IsMenu = isMenu;
|
||||
|
||||
|
Reference in New Issue
Block a user