(no commit message)
authorAsh Tyndall <[email protected]>
Sat, 8 Oct 2011 06:45:27 +0000 (14:45 +0800)
committerAsh Tyndall <[email protected]>
Sat, 8 Oct 2011 06:45:27 +0000 (14:45 +0800)
scene.c

diff --git a/scene.c b/scene.c
index bc91f1e..53b3187 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -267,7 +267,7 @@ int makeSubmenuFromArray( const char *menuEntries[], unsigned int menuEntriesSiz
     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
@@ -295,45 +295,28 @@ void makeMenu() {
   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

UCC git Repository :: git.ucc.asn.au