From: Ash Tyndall Date: Sat, 8 Oct 2011 06:45:27 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=27e1e38f04dae7d958de8ef3eb012f7e34864964;p=atyndall%2Fcits2231.git --- diff --git a/scene.c b/scene.c index bc91f1e..53b3187 100644 --- a/scene.c +++ b/scene.c @@ -267,7 +267,7 @@ int makeSubmenuFromArray( const char *menuEntries[], unsigned int menuEntriesSiz int startNum = i*11 - (i-1); int endNum = startNum + 9; if ( i == menuNumber - 1 ) { // We're on the last one - endNum = startNum + (menuEntriesSize - startNum); + endNum = startNum + (menuEntriesSize - startNum); // Work out final number } sprintf(name, "%d-%d", startNum, endNum); glutAddSubMenu( name, submenuObjects[i] ); @@ -295,45 +295,28 @@ void makeMenu() { glutAddMenuEntry("Move Light 2", LIGHT_MOVE_LIGHT_2); glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2); - // Construct add object submenus + // Construct object menu int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]); - int addObjectMenu = makeSubmenuFromArray( objectMenuEntries, objectMenuEntriesSize, processObjectEvents ); - - // Construct texture/ground texture submenus -/* int textureMenuEntries = sizeof(textureMenuEntries) / sizeof(textureMenuEntries[0]); - int menuNumber = textureMenuEntries / 10 + 1; - int textureSubmenu[menuNumber-1]; - - for( int i = 0; i < menuNumber; i++ ) { - textureSubmenu[i] = glutCreateMenu(processTextureEvents); - int startNum = i*11 - (i-1); - for ( int j = startNum - 1; j < (startNum+9); j++ ) { - if ( j == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array - glutAddMenuEntry( objectMenuEntries[j], j ); - } - }*/ + int objectMenu = makeSubmenuFromArray( objectMenuEntries, objectMenuEntriesSize, processObjectEvents ); + // Construct texture / ground texture menus + int textureMenuEntriesSize = sizeof(textureMenuEntries) / sizeof(textureMenuEntries[0]); + int textureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processTextureEvents ); + int gTextureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processGTextureEvents ); + // Construct main menu int mainMenu = glutCreateMenu(processMainEvents); - glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA); - glutAddSubMenu("Add object", addObjectMenu); + glutAddSubMenu("Add object", objectMenu); glutAddMenuEntry("Position/Scale", POSITION_SCALE); glutAddMenuEntry("Rotation/Texture Scale", ROTATION_TEXTURE_SCALE); - //material - - - - glutSetMenu(mainMenu); glutAddSubMenu("Material", materialMenu); - - //texture - //ground texture - //lights - - + glutAddSubMenu("Texture", textureMenu); + glutAddSubMenu("Ground texture", gTextureMenu); + glutAddSubMenu("Lights", lightMenu); glutAddMenuEntry("Exit", EXIT); + // Bind to right mouse button glutAttachMenu(GLUT_RIGHT_BUTTON); }