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 + (menuEntriesSize - startNum);\r
+ endNum = startNum + (menuEntriesSize - startNum); // Work out final number\r
}\r
sprintf(name, "%d-%d", startNum, endNum);\r
glutAddSubMenu( name, submenuObjects[i] );\r
glutAddMenuEntry("Move Light 2", LIGHT_MOVE_LIGHT_2);\r
glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2);\r
\r
- // Construct add object submenus\r
+ // Construct object menu\r
int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]);\r
- int addObjectMenu = makeSubmenuFromArray( objectMenuEntries, objectMenuEntriesSize, 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
- 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
+ int objectMenu = makeSubmenuFromArray( objectMenuEntries, objectMenuEntriesSize, processObjectEvents );\r
\r
+ // Construct texture / ground texture menus\r
+ int textureMenuEntriesSize = sizeof(textureMenuEntries) / sizeof(textureMenuEntries[0]);\r
+ int textureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processTextureEvents );\r
+ int gTextureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processGTextureEvents );\r
\r
+ // Construct main menu\r
int mainMenu = glutCreateMenu(processMainEvents);\r
-\r
glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA);\r
- glutAddSubMenu("Add object", addObjectMenu);\r
+ glutAddSubMenu("Add object", objectMenu);\r
glutAddMenuEntry("Position/Scale", POSITION_SCALE);\r
glutAddMenuEntry("Rotation/Texture Scale", ROTATION_TEXTURE_SCALE);\r
- //material\r
- \r
- \r
-\r
- glutSetMenu(mainMenu);\r
glutAddSubMenu("Material", materialMenu);\r
- \r
- //texture\r
- //ground texture\r
- //lights\r
-\r
-\r
+ glutAddSubMenu("Texture", textureMenu);\r
+ glutAddSubMenu("Ground texture", gTextureMenu);\r
+ glutAddSubMenu("Lights", lightMenu);\r
glutAddMenuEntry("Exit", EXIT);\r
\r
+ // Bind to right mouse button\r
glutAttachMenu(GLUT_RIGHT_BUTTON);\r
}\r
\r