0% found this document useful (0 votes)
72 views2 pages

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

This lab expands on the previous lab by adding a menu to select axis and object colors. When the right mouse button is clicked, a "Color" menu will appear with submenus for "Blue", "Green", and "Yellow" axis colors. GLUT is used to create the menu and submenus, add menu entries linked to functions, and attach the menu to the right mouse button. Bronze and Silver challenges extend the menu to also select unit label colors and geometric drawing types, while the Golden challenge is to draw a multi-colored star shape.

Uploaded by

Sen Sokha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views2 pages

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

This lab expands on the previous lab by adding a menu to select axis and object colors. When the right mouse button is clicked, a "Color" menu will appear with submenus for "Blue", "Green", and "Yellow" axis colors. GLUT is used to create the menu and submenus, add menu entries linked to functions, and attach the menu to the right mouse button. Bronze and Silver challenges extend the menu to also select unit label colors and geometric drawing types, while the Golden challenge is to draw a multi-colored star shape.

Uploaded by

Sen Sokha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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