projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial work on callbacks with user data parameters.
[freeglut]
/
src
/
fg_structure.c
diff --git
a/src/fg_structure.c
b/src/fg_structure.c
index
2a65b69
..
c279b4a
100644
(file)
--- a/
src/fg_structure.c
+++ b/
src/fg_structure.c
@@
-1,5
+1,5
@@
/*
/*
- * freeglut_structure.c
+ * fg_structure.c
*
* Windows and menus need tree structure
*
*
* Windows and menus need tree structure
*
@@
-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) );
/* 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 );
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
/*
* Open the window now. The fgOpenWindow() function is system
- * dependant, and resides in freeglut_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) );
*/
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
*/
/*
* 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;
{
SFG_Window *current_window = fgStructure.CurrentWindow;
@@
-129,10
+134,11
@@
SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
fgSetWindow( current_window );
/* Initialize the object properties: */
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 );
fgListInit( &menu->Entries );
fgListAppend( &fgStructure.Menus, &menu->Node );
@@
-190,7
+196,7
@@
void fgCloseWindows( )
/*
* This function destroys a window and all of its subwindows. Actually,
/*
* This function destroys a window and all of its subwindows. Actually,
- * another function, defined in freeglut_window.c is called, but this is
+ * another function, defined in fg_window.c is called, but this is
* a whole different story...
*/
void fgDestroyWindow( SFG_Window* window )
* a whole different story...
*/
void fgDestroyWindow( SFG_Window* window )
@@
-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
* 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 )
{
*/
void fgCreateStructure( void )
{
@@
-465,7
+471,7
@@
static void fghcbWindowByHandle( SFG_Window *window,
/*
* fgWindowByHandle returns a (SFG_Window *) value pointing to the
* first window in the queue matching the specified window handle.
/*
* fgWindowByHandle returns a (SFG_Window *) value pointing to the
* first window in the queue matching the specified window handle.
- * The function is defined in freeglut_structure.c file.
+ * The function is defined in fg_structure.c file.
*/
SFG_Window* fgWindowByHandle ( SFG_WindowHandleType hWindow )
{
*/
SFG_Window* fgWindowByHandle ( SFG_WindowHandleType hWindow )
{
@@
-506,7
+512,7
@@
static void fghcbWindowByID( SFG_Window *window, SFG_Enumerator *enumerator )
/*
* This function is similar to the previous one, except it is
* looking for a specified (sub)window identifier. The function
/*
* This function is similar to the previous one, except it is
* looking for a specified (sub)window identifier. The function
- * is defined in freeglut_structure.c file.
+ * is defined in fg_structure.c file.
*/
SFG_Window* fgWindowByID( int windowID )
{
*/
SFG_Window* fgWindowByID( int windowID )
{
@@
-568,7
+574,7
@@
static void fghcbGetActiveMenu( SFG_Menu *menu,
if ( enumerator->found )
return;
if ( enumerator->found )
return;
- /* Check the menu's ID. */
+ /* Check the menu's is active */
if( menu->IsActive )
{
enumerator->found = GL_TRUE;
if( menu->IsActive )
{
enumerator->found = GL_TRUE;
@@
-580,6
+586,7
@@
static void fghcbGetActiveMenu( SFG_Menu *menu,
/*
* Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
/*
* Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
+ * This is false when a submenu is also open.
* This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
*/
SFG_Menu* fgGetActiveMenu( )
* This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
*/
SFG_Menu* fgGetActiveMenu( )