Royal University of Phnom Penh CG: Lab 3 Faculty of Engineering Lecture: Kor Sokchea

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Royal University of Phnom Penh CG: Lab 3

Faculty of Engineering Lecture: Kor Sokchea

Lab 3:
In this lab, you will enhance your application that you have done in Lab 2 by adding a menu.
When the user clicks on the right-button of the mouse, a menu called color will appear on the
screen. Under this menu, it contains 3 submenu Blue, Green, and Yellow.
In order to create menu, we will use GLUT utility library as follows:
Create variable in order to store menu
int submenu;
int menu;

Create submenu

submenu = glutCreateMenu(selectAxisColor)
// the selectColor is the function that will will create in
order to response when the user select on each item on the
menu

Add item to submenu

glutAddMenuEntry(Blue, 1); // add the blue at the first row of the submenu
glutAddMenuEntry(green, 2); // add the green at the second row of the submenu
glutAddMenuEntry(yellow, 3); // add the green at the second row of the submenu

// the selectColor is the function that will will create


Create menu
menu = glutCreateMenu(selectAxisColor)
// the selectColor is the function that will will create in
order to response when the user select on each item on the
menu

Add submenu to menu


glutAddSubMenu(Axis Color, submenu); // add the blue at the first row of the
submenu
// attach menu to the right button of the mouse
glutAttachMenu(GLUT_RIGHT_BUTTON);
Royal University of Phnom Penh CG: Lab 3
Faculty of Engineering Lecture: Kor Sokchea

Bronze Challenge: Changing the color of the both x-axis and y-axis to the selected
color.

Silver Challenge: Adding two more submenu called unit color and geometric type.
Under unit color, it consists of Brown, Cyan, White. Under geometric type
submenu, it has Point and Line Strip or Line Loop. It depends on which one you use
to draw sine wave. When the user selects one color under unit color submenu, the
unit label will change color corresponding to what the user selected. The same for
geometric type.

Golden Challenge: draw a nice star shape and color it with different color on each
section.

You might also like