Initial work on callbacks with user data parameters.
[freeglut] / src / fg_structure.c
index 5a6ce95..c279b4a 100644 (file)
@@ -75,6 +75,11 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
     /* Have the window object created */
     SFG_Window *window = (SFG_Window *)calloc( 1, sizeof(SFG_Window) );
 
+    if( !window )
+    {
+        fgError( "Out of memory. Could not create window." );
+    }
+
        fgPlatformCreateWindow ( window );
 
     fghClearCallBacks( window );
@@ -100,7 +105,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
 
     /*
      * Open the window now. The fgOpenWindow() function is system
-     * dependant, and resides in fg_window.c. Uses fgState.
+     * dependent, and resides in fg_window.c. Uses fgState.
      */
     fgOpenWindow( window, title, positionUse, x, y, sizeUse, w, h, gameMode,
                   (GLboolean)(parent ? GL_TRUE : GL_FALSE) );
@@ -111,7 +116,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
 /*
  * This private function creates a menu and adds it to the menus list
  */
-SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
+SFG_Menu* fgCreateMenu( FGCBMenuUC menuCallback, FGCBUserData userData )
 {
     SFG_Window *current_window = fgStructure.CurrentWindow;
 
@@ -129,10 +134,11 @@ SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
     fgSetWindow( current_window );
 
     /* Initialize the object properties: */
-    menu->ID       = ++fgStructure.MenuID;
-    menu->Callback = menuCallback;
-    menu->ActiveEntry = NULL;
-    menu->Font     = fgState.MenuFont;
+    menu->ID           = ++fgStructure.MenuID;
+    menu->Callback     = menuCallback;
+    menu->CallbackData = userData;
+    menu->ActiveEntry  = NULL;
+    menu->Font         = fgState.MenuFont;
 
     fgListInit( &menu->Entries );
     fgListAppend( &fgStructure.Menus, &menu->Node );
@@ -332,7 +338,7 @@ void fgDestroyMenu( SFG_Menu* menu )
  * This function should be called on glutInit(). It will prepare the internal
  * structure of freeglut to be used in the application. The structure will be
  * destroyed using fgDestroyStructure() on glutMainLoop() return. In that
- * case further use of freeglut should be preceeded with a glutInit() call.
+ * case further use of freeglut should be preceded with a glutInit() call.
  */
 void fgCreateStructure( void )
 {