\r
}\r
\r
+int makeSubmenuFromArray( const char *menuEntries[], void *callback ) {\r
+ int menuEntriesSize = sizeof(menuEntries) / sizeof(menuEntries[0]);\r
+ int menuNumber = menuEntriesSize / 10 + 1;\r
+ int submenuObjects[menuNumber-1];\r
\r
+ for( int i = 0; i < menuNumber; i++ ) {\r
+ submenuObjects[i] = glutCreateMenu(callback);\r
+ int startNum = i*11 - (i-1);\r
+ for ( int j = startNum - 1; j < (startNum+9); j++ ) {\r
+ if ( j == menuEntriesSize ) break; // Detect if we've reached the end of the array\r
+ glutAddMenuEntry( menuEntries[j], j );\r
+ }\r
+ }\r
+\r
+ int mainMenu = glutCreateMenu(callback);\r
+ for ( int i = 0; i < menuNumber; i++ ) {\r
+ char name[10]; // buffer to hold name\r
+ int startNum = i*11 - (i-1);\r
+ int endNum = startNum + 9;\r
+ if ( i == menuNumber - 1 ) { // We're on the last one\r
+ endNum = startNum + 3;\r
+ }\r
+ sprintf(name, "%d-%d", startNum, endNum);\r
+ glutAddSubMenu( name, submenuObjects[i] );\r
+ }\r
+\r
+ return mainMenu;\r
+}\r
\r
void makeMenu() {\r
// Construct material menu\r
glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2);\r
\r
// Construct add object submenus\r
- int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]);\r
- int menuNumber = objectMenuEntriesSize / 10 + 1;\r
- int addObjectSubmenu[menuNumber-1];\r
+ int addObjectMenu = makeSubmenuFromArray( objectMenuEntries, processObjectEvents );\r
+\r
+ // Construct texture/ground texture submenus\r
+/* int textureMenuEntries = sizeof(textureMenuEntries) / sizeof(textureMenuEntries[0]);\r
+ int menuNumber = textureMenuEntries / 10 + 1;\r
+ int textureSubmenu[menuNumber-1];\r
\r
for( int i = 0; i < menuNumber; i++ ) {\r
- addObjectSubmenu[i] = glutCreateMenu(processObjectEvents);\r
+ textureSubmenu[i] = glutCreateMenu(processTextureEvents);\r
int startNum = i*11 - (i-1);\r
for ( int j = startNum - 1; j < (startNum+9); j++ ) {\r
if ( j == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array\r
glutAddMenuEntry( objectMenuEntries[j], j );\r
}\r
- }\r
-\r
- // Construct add object menu\r
- int addObjectMenu = glutCreateMenu(processObjectEvents);\r
- for ( int i = 0; i < menuNumber; i++ ) {\r
- char name[10]; // buffer to hold name\r
- int startNum = i*11 - (i-1);\r
- int endNum = startNum + 9;\r
- if ( i == menuNumber - 1 ) { // We're on the last one\r
- endNum = startNum + 3;\r
- }\r
- sprintf(name, "%d-%d", startNum, endNum);\r
- glutAddSubMenu( name, addObjectSubmenu[i] );\r
- }\r
+ }*/\r
\r
\r
int mainMenu = glutCreateMenu(processMainEvents);\r