+int timerInts[] = {
+ 250,
+ 500,
+ 1000
+};
+int timerSurroundInt = 1000, timerCenterInt = 1000;
+
+/* menu IDs, creation/update funcs and callback */
+int menuID, subMenuSurround, subMenuCenter;
+
+void createMenuEntries(int which)
+{
+ for (int i = 0; i < sizeof(timerInts) / sizeof(*timerInts); i++)
+ {
+ char temp[10] = {'\0'};
+ /* flag current value */
+ if ((which == 1 ? timerSurroundInt : timerCenterInt) == timerInts[i])
+ temp[0] = '+';
+ else
+ temp[0] = '-';
+
+ sprintf(temp + 1, " %4d ms", timerInts[i]);
+
+ glutAddMenuEntry(temp, timerInts[i]);
+ }
+}
+
+void updateMenuEntries(int which)
+{
+ for (int i = 0; i < sizeof(timerInts) / sizeof(*timerInts); i++)
+ {
+ char temp[10] = { '\0' };
+ /* flag current value */
+ if ((which == 1 ? timerSurroundInt : timerCenterInt) == timerInts[i])
+ temp[0] = '+';
+ else
+ temp[0] = '-';
+
+ sprintf(temp + 1, " %4d ms", timerInts[i]);
+
+ glutChangeToMenuEntry(i+1, temp, timerInts[i]);
+ }
+}
+\r
+void MenuSurround(int timerInt)\r
+{\r
+ timerSurroundInt = timerInt;\r
+ glutSetMenu(subMenuSurround);\r
+ updateMenuEntries(1);\r
+}
+void MenuCenter(int timerInt)\r
+{\r
+ timerCenterInt = timerInt;\r
+ glutSetMenu(subMenuCenter);\r
+ updateMenuEntries(2);\r
+}