X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=80e81fff3403b469c8d4ac9617a1e9e3e8ef8138;hb=4b37cb99145f3d4911f7b726ec5189f9b1978c43;hp=5b3f3a881cee768997108717452c1d40daf8d629;hpb=e621bfb4edf5934205815019f7ce7b4e4491c72b;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 5b3f3a8..80e81ff 100644 --- a/scene.c +++ b/scene.c @@ -268,11 +268,15 @@ void makeMenu() { glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2); // Construct add object submenus - int addObjectSubmenu[6]; + int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]); + int menuNumber = objectMenuEntriesSize / 10 + 1; + int addObjectSubmenu[menuNumber-1]; - for( int i = 0; i < 6; i++ ) { + for( int i = 0; i < menuNumber; i++ ) { addObjectSubmenu[i] = glutCreateMenu(processObjectEvents); - for ( int j = i; j < (i+9); j++ ) { + int startNum = i*11 - (i-1); + for ( int j = startNum - 1; j < (startNum+9); j++ ) { + if ( j == objectMenuEntriesSize - 1 ) break; // Detect if we've reached the end of the array glutAddMenuEntry( objectMenuEntries[j], j ); } } @@ -280,14 +284,17 @@ void makeMenu() { // Construct add object menu int addObjectMenu = glutCreateMenu(processObjectEvents); for ( int i = 0; addObjectSubmenu[i]; i++ ) { - glutAddSubMenu( "1", addObjectSubmenu[i] ); + char name[10]; // buffer to hold name + int startNum; i*11 - (i-1); + sprintf(name, "%d-%d", startNum, startNum + 9); + glutAddSubMenu( name, addObjectSubmenu[i] ); } int mainMenu = glutCreateMenu(processMainEvents); glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA); - //Add object + glutAddSubMenu("Add object", addObjectMenu); glutAddMenuEntry("Position/Scale", POSITION_SCALE); glutAddMenuEntry("Rotation/Texture Scale", ROTATION_TEXTURE_SCALE); //material