int x, int y, int w, int h,
GLboolean gameMode, GLboolean isMenu )
{
int x, int y, int w, int h,
GLboolean gameMode, GLboolean isMenu )
{
- /*
- * If the freeglut internals haven't been initialized yet,
- * do it now. Hack's idea courtesy of Chris Purnell...
- */
- if( !fgState.Initialised )
- glutInit( &fakeArgc, NULL );
-
- /*
- * Initialize the object properties
- */
+ /* Initialize the object properties */
/*
* Open the window now. The fgOpenWindow() function is system
* dependant, and resides in freeglut_window.c. Uses fgState.
*/
fgOpenWindow( window, title, x, y, w, h, gameMode,
/*
* Open the window now. The fgOpenWindow() function is system
* dependant, and resides in freeglut_window.c. Uses fgState.
*/
fgOpenWindow( window, title, x, y, w, h, gameMode,
SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
{
int x = 100, y = 100, w = 100, h = 100;
SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
{
int x = 100, y = 100, w = 100, h = 100;
- /*
- * If the freeglut internals haven't been initialized yet,
- * do it now. Hack's idea courtesy of Chris Purnell...
- */
- if( !fgState.Initialised )
- glutInit( &fakeArgc, NULL );
+ menu->ParentWindow = NULL;
- /*
- * Create a window for the menu to reside in.
- */
-
- fgCreateWindow( NULL, NULL, x, y, w, h, GL_FALSE, GL_TRUE );
- menu->Window = fgStructure.Window;
+ fgCreateWindow( NULL, "freeglut menu", x, y, w, h, GL_FALSE, GL_TRUE );
+ menu->Window = fgStructure.CurrentWindow;
glutDisplayFunc( fgDisplayMenu );
glutHideWindow( ); /* Hide the window for now */
fgSetWindow( current_window );
glutDisplayFunc( fgDisplayMenu );
glutHideWindow( ); /* Hide the window for now */
fgSetWindow( current_window );
menu->ID = ++fgStructure.MenuID;
menu->Callback = menuCallback;
menu->ActiveEntry = NULL;
menu->ID = ++fgStructure.MenuID;
menu->Callback = menuCallback;
menu->ActiveEntry = NULL;
fgListInit( &menu->Entries );
fgListAppend( &fgStructure.Menus, &menu->Node );
fgListInit( &menu->Entries );
fgListAppend( &fgStructure.Menus, &menu->Node );
new_list_entry->window = window;
fgListAppend( &fgStructure.WindowsToDestroy, &new_list_entry->node );
new_list_entry->window = window;
fgListAppend( &fgStructure.WindowsToDestroy, &new_list_entry->node );
- /*
- * Check if the window is the current one...
- */
- if( fgStructure.Window == window )
- fgStructure.Window = NULL;
+ /* Check if the window is the current one... */
+ if( fgStructure.CurrentWindow == window )
+ fgStructure.CurrentWindow = NULL;
- void *destroy = FETCH_WCB( *window, Destroy );
- fgClearCallBacks( window );
- FETCH_WCB( *window, Destroy ) = destroy;
+ FGCBDestroy destroy = (FGCBDestroy)FETCH_WCB( *window, Destroy );
+ fghClearCallBacks( window );
+ SET_WCB( *window, Destroy, destroy );
fgDestroyWindow( window_ptr->window );
fgListRemove( &fgStructure.WindowsToDestroy, &window_ptr->node );
free( window_ptr );
fgDestroyWindow( window_ptr->window );
fgListRemove( &fgStructure.WindowsToDestroy, &window_ptr->node );
free( window_ptr );
- for ( menu_index = 0; menu_index < 3; menu_index ++ )
- {
- if ( window->Menu[menu_index] )
- window->Menu[menu_index]->ParentWindow = NULL ;
- }
-
- fgClearCallBacks( window );
+ fghClearCallBacks( window );
/*
* Check if the menu is attached to the current window,
* if so, have it detached (by overwriting with a NULL):
*/
/*
* Check if the menu is attached to the current window,
* if so, have it detached (by overwriting with a NULL):
*/
for( subWindow = (SFG_Window *)window->Children.First;
subWindow;
subWindow = (SFG_Window *)subWindow->Node.Next)
for( subWindow = (SFG_Window *)window->Children.First;
subWindow;
subWindow = (SFG_Window *)subWindow->Node.Next)
for( window = (SFG_Window *)fgStructure.Windows.First;
window;
window = (SFG_Window *)window->Node.Next )
fghRemoveMenuFromWindow( window, menu );
for( window = (SFG_Window *)fgStructure.Windows.First;
window;
window = (SFG_Window *)window->Node.Next )
fghRemoveMenuFromWindow( window, menu );
fgDestroyWindow( menu->Window );
fgListRemove( &fgStructure.Menus, &menu->Node );
fgDestroyWindow( menu->Window );
fgListRemove( &fgStructure.Menus, &menu->Node );
fgListInit(&fgStructure.Windows);
fgListInit(&fgStructure.Menus);
fgListInit(&fgStructure.WindowsToDestroy);
fgListInit(&fgStructure.Windows);
fgListInit(&fgStructure.Menus);
fgListInit(&fgStructure.WindowsToDestroy);
+
+ fgStructure.CurrentWindow = NULL;
+ fgStructure.CurrentMenu = NULL;
+ fgStructure.MenuContext = NULL;
+ fgStructure.GameMode = NULL;
+ fgStructure.WindowID = 0;
+ fgStructure.MenuID = 0;
- /*
- * Make sure all windows and menus have been deallocated
- */
- while( menu = ( SFG_Menu * )fgStructure.Menus.First )
- fgDestroyMenu( menu );
+ /* Make sure all windows and menus have been deallocated */
+ while( fgStructure.Menus.First )
+ fgDestroyMenu( ( SFG_Menu * )fgStructure.Menus.First );
for( window = ( SFG_Window * )fgStructure.Windows.First;
window;
window = ( SFG_Window * )window->Node.Next )
for( window = ( SFG_Window * )fgStructure.Windows.First;
window;
window = ( SFG_Window * )window->Node.Next )
- assert( enumCallback && enumerator );
- freeglut_assert_ready;
+ FREEGLUT_INTERNAL_ERROR_EXIT ( enumCallback && enumerator,
+ "Enumerator or callback missing from subwindow enumerator call",
+ "fgEnumSubWindows" );
+ FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Window Enumeration" );
if( window->Window.Handle == (SFG_WindowHandleType) (enumerator->data) )
{
enumerator->found = GL_TRUE;
if( window->Window.Handle == (SFG_WindowHandleType) (enumerator->data) )
{
enumerator->found = GL_TRUE;
enumerator.found = GL_FALSE;
enumerator.data = (void *)hWindow;
fgEnumWindows( fghcbWindowByHandle, &enumerator );
enumerator.found = GL_FALSE;
enumerator.data = (void *)hWindow;
fgEnumWindows( fghcbWindowByHandle, &enumerator );
- /*
- * Check the window's handle. Hope this works. Looks ugly. That's for sure.
- */
- if( window->ID == (int) (enumerator->data) ) /* XXX int/ptr conversion! */
+ /* Check the window's handle. Hope this works. Looks ugly. That's for sure. */
+ if( window->ID == *( int *)(enumerator->data) )
- SFG_Node *ln;
-
- if( ln = (SFG_Node *)node->Next )
- ln->Prev = node->Prev;
- if( ln = (SFG_Node *)node->Prev )
- ln->Next = node->Next;
- if( (ln = (SFG_Node *)list->First) == node )
+ if( node->Next )
+ ( ( SFG_Node * )node->Next )->Prev = node->Prev;
+ if( node->Prev )
+ ( ( SFG_Node * )node->Prev )->Next = node->Next;
+ if( ( ( SFG_Node * )list->First ) == node )