\r
}\r
\r
+/**\r
+ * Rounds up numbers, from http://stackoverflow.com/questions/3407012/c-rounding-up-to-the-nearest-multiple-of-a-number\r
+ * @param numToRound Number to round\r
+ * @param multiple Multiple to round up to\r
+ * @return Rounded number\r
+ */\r
int roundUp(int numToRound, int multiple) {\r
if(multiple == 0) {\r
return numToRound;\r
return numToRound + multiple - remainder;\r
}\r
\r
+/**\r
+ * Makes a submenu from an array of items, splitting the list into subsubmenus\r
+ * of only 10 items.\r
+ * @param menuEntries Array of menu items\r
+ * @param menuEntriesSize Size of menuEntries\r
+ * @param callback Callback function for this array of menu items\r
+ * @return Reference to menu created\r
+ */\r
int makeSubmenuFromArray( const char *menuEntries[], unsigned int menuEntriesSize, void *callback ) {\r
if ( menuEntriesSize == 0 ) return -1;\r
\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
+ glutAddMenuEntry( menuEntries[j], j + 1 );\r
}\r
- }\r
+ } \r
\r
int mainMenu = glutCreateMenu(callback);\r
for ( int i = 0; i < menuNumber; i++ ) {\r