/*写出当前是哪个菜单*/
void GetCurrentMenu(void)
{
int nMenu;
nMenu = glutGetMenu();
if(nMenu == menu)
printf("The current menu is Main Menu.\n");
if(nMenu == subMenu1)
printf("The current menu is SubMenu1.\n");
if(nMenu == subMenu2)
printf("The current menu is SubMenu2.\n");
}
/*子菜单1*/
void SubMenuFunc1(int data)
{
GetCurrentMenu();
switch(data)
{
case 1:
printf("SubMenu1's item 1 is triggered.\n");
break;
case 2:
printf("SubMenu1's item 2 is triggered.\n");
break;
case 3:
printf("SubMenu1's item 3 is triggered.\n");
break;
}
}
/*子菜单2*/
void SubMenuFunc2(int data)
{
GetCurrentMenu();
switch(data)
{
case 1:
printf("SubMenu2's item 1 is triggered.\n");
break;
case 2:
printf("SubMenu2's item 2 is triggered.\n");
break;
case 3:
printf("SubMenu2's item 3 is triggered.\n");
break;
}
}
/*主菜单*/
void MenuFunc(int data)
{
GetCurrentMenu();
switch(data)
{
case 1:
printf("MainMenu's item 1 is triggered.\n");
break;
case 2:
printf("MainMenu's item 2 is triggered.\n");
break;
case 3:
printf("MainMenu's item 3 is triggered.\n");
break;
}
}