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;
- int fakeArgc = 0;
-
- /*
- * 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 );
- 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;
- FGCBDestroy destroy = FETCH_WCB( *window, Destroy );
- fgClearCallBacks( window );
+ FGCBDestroy destroy = (FGCBDestroy)FETCH_WCB( *window, Destroy );
+ fghClearCallBacks( window );
INVOKE_WCB( *window, Destroy, ( ) );
fgSetWindow( activeWindow );
}
INVOKE_WCB( *window, Destroy, ( ) );
fgSetWindow( activeWindow );
}
- 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;
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 );
enumerator.found = GL_FALSE;
enumerator.data = ( void * )&windowID;
fgEnumWindows( fghcbWindowByID, &enumerator );
enumerator.found = GL_FALSE;
enumerator.data = ( void * )&windowID;
fgEnumWindows( fghcbWindowByID, &enumerator );