/* modify your main function something like this... */ void main( void ) { GLint objMenu, matlMenu; . . . /* Most of your initialization and GLUT initialization goes here */ . . . /* Object Menu */ objMenu = glutCreateMenu( menuCallback ); glutAddMenuEntry("(X) Al Capone", 200); glutAddMenuEntry("( ) Stanford Bunny", 201); glutAddMenuEntry("( ) Stanford Dragon", 202); glutAddMenuEntry("( ) Utah Teapot", 203); /* Material menu */ matlMenu = glutCreateMenu( menuCallback ); glutAddMenuEntry("(X) Brass", 300); // <--- the number is the value passed to the menu callback glutAddMenuEntry("( ) Pewter", 301); glutAddMenuEntry("( ) Emerald", 302); glutAddMenuEntry("( ) Black Plastic", 303); /* Main menu */ glutCreateMenu( menuCallback ); glutAddSubMenu("Object Selection", objMenu ); glutAddSubMenu("Material Selection", matlMenu ); glutAddMenuEntry(" ", 0 ); glutAddMenuEntry("Quit", 27); glutAttachMenu(GLUT_RIGHT_BUTTON); // attaches the current menu to the right button // (the current one is the last one created!) . . . /* start yout glutMainLoop() down here */ . . . } /* add menu callback a menu callback something like this... */ void menuCallback( int value ) { switch (value) { default: break; case 200: // User selected menu item "Al Capone". Deal with it! break; case 201: // User selected menu item "Stanford Bunny". Deal with it! break; case 202: // User selected menu item "Stanford Dragon". Deal with it! break; case 203: // User selected menu item "Utah Teapot". Deal with it! break; case 300: // User selected menu item "Brass". Deal with it! break; case 301: // User selected menu item "Pewter". Deal with it! break; case 302: // User selected menu item "Emerald". Deal with it! break; case 303: // User selected menu item "Black Plastic". Deal with it! break; case 27: // User selected "Quit"! exit(0); break; } glutPostRedisplay(); }