OpenGL-GLUT tutorial (11) glut sub-menu

Source: Internet
Author: User

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)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.