+ // Construct material menu\r
+ int materialMenu = glutCreateMenu(processMaterialEvents);\r
+ glutAddMenuEntry("All R/G/B", MATERIAL_ALL_RGB);\r
+ glutAddMenuEntry("Ambient R/G/B", MATERIAL_AMBIENT_RGB);\r
+ glutAddMenuEntry("Diffuse R/G/B", MATERIAL_DIFFUSE_RGB);\r
+ glutAddMenuEntry("Specular R/G/B", MATERIAL_SPECULAR_RGB);\r
+ glutAddMenuEntry("All Amb/Diff/Spec/Shine", MATERIAL_ALL_ADSS);\r
+ glutAddMenuEntry("Red Amb/Diff/Spec/Shine", MATERIAL_RED_ADSS);\r
+ glutAddMenuEntry("Green Amb/Diff/Spec/Shine", MATERIAL_GREEN_ADSS);\r
+ glutAddMenuEntry("Blue Amb/Diff/Spec/Shine", MATERIAL_BLUE_ADSS);\r
+\r
+ // Construct light menu\r
+ int lightMenu = glutCreateMenu(processLightEvents);\r
+ glutAddMenuEntry("Move Light 1", LIGHT_MOVE_LIGHT_1);\r
+ glutAddMenuEntry("R/G/B/All Light 1", LIGHT_RGBALL_LIGHT_1);\r
+ glutAddMenuEntry("Move Light 2", LIGHT_MOVE_LIGHT_2);\r
+ glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2);\r
+\r
+ // Construct object menu\r
+ int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]);\r
+ int objectMenu = makeSubmenuFromArray( objectMenuEntries, objectMenuEntriesSize, processObjectEvents );\r
+\r
+ // Construct texture / ground texture menus\r
+ int textureMenuEntriesSize = sizeof(textureMenuEntries) / sizeof(textureMenuEntries[0]);\r
+ int textureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processTextureEvents );\r
+ int gTextureMenu = makeSubmenuFromArray( textureMenuEntries, textureMenuEntriesSize, processGTextureEvents );\r
+\r
+ // Construct main menu\r
+ glutCreateMenu(processMainEvents);\r
+ //glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA);\r
+ //glutAddSubMenu("Add object", objectMenu);\r
+ //glutAddMenuEntry("Position/Scale", POSITION_SCALE);\r
+ //glutAddMenuEntry("Rotation/Texture Scale", ROTATION_TEXTURE_SCALE);\r
+ //glutAddSubMenu("Material", materialMenu);\r
+ //glutAddSubMenu("Texture", textureMenu);\r
+ //glutAddSubMenu("Ground texture", gTextureMenu);\r
+ //glutAddSubMenu("Lights", lightMenu);\r
+ glutAddMenuEntry("Exit", EXIT);\r
+\r
+ // Bind to right mouse button\r
+ glutAttachMenu(GLUT_RIGHT_BUTTON);\r
+}\r
+\r
+/**\r
+ * Called when window is resized\r
+ * @param w New width\r
+ * @param h New height\r
+ */\r
+void windowReshape(int w, int h) {\r
+ GLdouble near = -10.0;\r
+ GLdouble far = 10.0;\r
+\r
+ glViewport(0, 0, (GLsizei) w, (GLsizei) h);\r
+ glMatrixMode(GL_PROJECTION);\r
+ glLoadIdentity();\r
+ if (w <= h) \r
+ glOrtho(near, far, near*(GLfloat)h/(GLfloat)w,\r
+ far*(GLfloat)h/(GLfloat)w, near, far);\r
+ else\r
+ glOrtho(near*(GLfloat)w/(GLfloat)h,\r
+ far*(GLfloat)w/(GLfloat)h, near, far, near, far);\r
+ glMatrixMode(GL_MODELVIEW); \r
+ glLoadIdentity();\r
+}\r