* 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"
-
/* -- GLOBAL EXPORTS ------------------------------------------------------- */
/*
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
-void fgClearCallBacks( SFG_Window *window )
+static void fghClearCallBacks( SFG_Window *window )
{
if( window )
{
{
/* Have the window object created */
SFG_Window *window = (SFG_Window *)calloc( sizeof(SFG_Window), 1 );
- int fakeArgc = 0;
- fgClearCallBacks( window );
-
- /*
- * 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 );
+ fghClearCallBacks( window );
/* Initialize the object properties */
window->ID = ++fgStructure.WindowID;
* dependant, and resides in freeglut_window.c. Uses fgState.
*/
fgOpenWindow( window, title, x, y, w, h, gameMode,
- parent ? GL_TRUE : GL_FALSE );
+ (GLboolean)(parent ? GL_TRUE : GL_FALSE) );
return window;
}
/* Have the menu object created */
SFG_Menu* menu = (SFG_Menu *)calloc( sizeof(SFG_Menu), 1 );
- 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 );
-
- menu->ParentWindow = fgStructure.Window;
+ menu->ParentWindow = NULL;
/* Create a window for the menu to reside in. */
*/
{
FGCBDestroy destroy = FETCH_WCB( *window, Destroy );
- fgClearCallBacks( window );
+ fghClearCallBacks( window );
SET_WCB( *window, Destroy, destroy );
}
}
*/
void fgDestroyWindow( SFG_Window* window )
{
- int menu_index;
-
- assert( window );
- freeglut_assert_ready;
+ FREEGLUT_INTERNAL_ERROR_EXIT ( window, "Window destroy function called with null window",
+ "fgDestroyWindow" );
while( window->Children.First )
fgDestroyWindow( ( SFG_Window * )window->Children.First );
if( window->ActiveMenu )
fgDeactivateMenu( window );
- for( menu_index = 0; menu_index < 3; menu_index ++ )
- if( window->Menu[ menu_index ] )
- window->Menu[ menu_index ]->ParentWindow = NULL;
-
- fgClearCallBacks( window );
+ fghClearCallBacks( window );
fgCloseWindow( window );
free( window );
if( fgStructure.Window == window )
SFG_Window *subWindow;
int i;
+ /* Check whether this is the active menu in the window */
+ if ( menu == window->ActiveMenu )
+ window->ActiveMenu = NULL ;
+
/*
* Check if the menu is attached to the current window,
* if so, have it detached (by overwriting with a NULL):
SFG_Window *window;
SFG_Menu *from;
- assert( menu );
- freeglut_assert_ready;
+ FREEGLUT_INTERNAL_ERROR_EXIT ( menu, "Menu destroy function called with null menu",
+ "fgDestroyMenu" );
/* First of all, have all references to this menu removed from all windows: */
for( window = (SFG_Window *)fgStructure.Windows.First;
}
if( fgStructure.Window == menu->Window )
- fgSetWindow( menu->ParentWindow );
+ fgSetWindow( NULL );
fgDestroyWindow( menu->Window );
fgListRemove( &fgStructure.Menus, &menu->Node );
if( fgStructure.Menu == menu )
*/
void fgDestroyStructure( void )
{
- freeglut_assert_ready;
-
/* Clean up the WindowsToDestroy list. */
fgCloseWindows( );
{
SFG_Window *window;
- assert( enumCallback && enumerator );
- freeglut_assert_ready;
+ FREEGLUT_INTERNAL_ERROR_EXIT ( enumCallback && enumerator,
+ "Enumerator or callback missing from window enumerator call",
+ "fgEnumWindows" );
/* Check every of the top-level windows */
for( window = ( SFG_Window * )fgStructure.Windows.First;
{
SFG_Window *child;
- 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" );
for( child = ( SFG_Window * )window->Children.First;
child;
{
SFG_Menu *menu = NULL;
- freeglut_assert_ready;
-
/* It's enough to check all entries in fgStructure.Menus... */
for( menu = (SFG_Menu *)fgStructure.Menus.First;
menu;