GLUT
Tutorial
Sub-menuIn the previous chapter, we learned how to create a simple menu. Now let's take a look at how to add a cascading submenu. The creation of sub-menus is the same as the function used to create menus. After creating a menu, we add the Sub-menu as an entry. Use the function maid to do this: void maid (char * entryname, int menuindex); parameter: entryname: Sub menu name. Menuindex: Sub-menu index. This is the value returned by the sub-menu. The above is the function for adding a sub-menu. (I think the sub-menu, that is, cascading menu, should all understand what it is ). Below is a short piece of code to illustrate the usefulness of the above function.
void createGLUTMenus() {
int menu,submenu;
submenu = glutCreateMenu(processMenuEvents);
glutAddMenuEntry("Red",RED);
glutAddMenuEntry("Blue",BLUE);
glutAddMenuEntry("Green",GREEN);
menu = glutCreateMenu(processMenuEvents);
glutAddMenuEntry("White",WHITE);
glutAddSubMenu("RGB Menu",submenu);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
Note that the functions used to process menu events are the same for menus and submenus. You can write a function to process submenu events by yourself. The source code of the vcss project is downloaded here (FIG)
(The Sub-menu is simple. You can create a sub-menu and add it as an entry in the main menu. Original address: http://www.lighthouse3d.com/opengl/glut/index.php? 11)