From: Christopher John Purnell Date: Sun, 16 Nov 2003 14:10:35 +0000 (+0000) Subject: Made Modifers variable global as per glut classic. X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;ds=sidebyside;h=2e8c8e1910a0f5a18c6108174bad31f13af38165;p=freeglut Made Modifers variable global as per glut classic. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@357 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/freeglut_init.c b/src/freeglut_init.c index c3de422..d271523 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -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,15 +456,16 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) char* geometry = NULL; int i, j, argc = *pargc; + if( fgState.Initalized ) + fgError( "illegal glutInit() reinitialization attemp" ); + 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( !fgState.ProgramName ) + fgError ("Could not allocate space for the program's name."); + } fgCreateStructure( ); diff --git a/src/freeglut_internal.h b/src/freeglut_internal.h index dec9867..5da2140 100644 --- a/src/freeglut_internal.h +++ b/src/freeglut_internal.h @@ -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 */ diff --git a/src/freeglut_main.c b/src/freeglut_main.c index f3d70ef..f976446 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -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; diff --git a/src/freeglut_state.c b/src/freeglut_state.c index 3c1ae79..9420de9 100644 --- a/src/freeglut_state.c +++ b/src/freeglut_state.c @@ -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 ); } /* diff --git a/src/freeglut_structure.c b/src/freeglut_structure.c index 3e55bfd..0824a34 100644 --- a/src/freeglut_structure.c +++ b/src/freeglut_structure.c @@ -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;