int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); //double buffering, RGB mode, need depth buffer glutInitWindowSize(WIDTH,HEIGHT); //width, height of the window glutInitWindowPosition(0, 0); // location on the screen the window appears window = glutCreateWindow("Project GUI"); // creates the window init(); //things to do once, mostly in beginning glutDisplayFunc(handleDisplay); // tells glut which function to call to render a screen. glutMotionFunc(handleMotion); // handle when motion (this generally means when mouse is moved with a button pressed) GLUI_Master.set_glutReshapeFunc( handleReshape ); //Setting opengl lights GLfloat light0_ambient[] = {0.1f, 0.1f, 0.3f, 1.0f}; GLfloat light0_diffuse[] = {.6f, .6f, 1.0f, 1.0f}; GLfloat light0_position[] = {1.0f, 1.0f, 1.0f, 0.0f}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glEnable(GL_DEPTH_TEST); // enabling depth GLUI *glui = GLUI_Master.create_glui_subwindow(window, GLUI_SUBWINDOW_RIGHT); new GLUI_StaticText( glui, "Project GLUI" ); new GLUI_Separator(glui); glui->set_main_gfx_window( window ); GLUI_Panel *obj_panel = glui->add_panel ("Display option panel"); listbox = new GLUI_Listbox(obj_panel, "Mesh display option", &display_type, 1, controlBlock); listbox->add_item(FLAT_SHADED, "Flat Shaded"); listbox->add_item(SMOOTH_SHADED, "Smooth Shaded"); listbox->add_item(WIREFRAME, "Wireframe"); listbox->add_item(EDGES_SHADED, "Shaded with mesh edges"); //scale code GLUI_Spinner *scale_spinner = new GLUI_Spinner( obj_panel, "Scale:", &scale); scale_spinner->set_float_limits( .2f, 5.0 ); scale_spinner->set_alignment( GLUI_ALIGN_RIGHT ); //rotation code GLUI_Panel * rotation_panel = glui->add_panel_to_panel(obj_panel, "", GLUI_PANEL_NONE); GLUI_Rotation *sph_rot = glui->add_rotation_to_panel(rotation_panel,"Rotate", sphere_rotate, ROTATION_ID, controlBlock); sph_rot->set_spin(1.0); //translation code GLUI_Panel * translate_panel = glui->add_panel_to_panel(obj_panel, "", GLUI_PANEL_NONE); GLUI_Translation * move_z = glui->add_translation_to_panel(translate_panel,"Object Z", GLUI_TRANSLATION_Z, &obj_pos[2]); move_z->scale_factor = 0.1f; glui->add_column_to_panel(translate_panel, true); GLUI_Translation * move_around = glui->add_translation_to_panel(translate_panel,"Object XY", GLUI_TRANSLATION_XY, obj_pos); move_around->scale_factor = 0.1f; GLUI_Panel * decimate_panel = glui->add_panel("Decimate Panel"); glui->add_edittext_to_panel(decimate_panel, "No. of collapse iteration: ", GLUI_EDITTEXT_INT, &collapseCount); glui->add_edittext_to_panel(decimate_panel, "Random count (k): ", GLUI_EDITTEXT_INT, &KValue); glui->add_button_to_panel(decimate_panel, "Decimate", DECIMATE_ID, controlBlock); glui->add_button_to_panel(decimate_panel, "Shape Preserve", SHAPE_PRESERVE_DECIMATE_ID, controlBlock); glui->add_separator(); GLUI_Panel * shape_panel = glui->add_panel("Shape based Panel"); glui->add_button_to_panel(shape_panel, "Go", SURE_SHAPE_PRESERVE_DECIMATE_ID, controlBlock); glui->add_separator(); GLUI_Panel * mapping_panel = glui->add_panel("Mapping Panel"); glui->add_button_to_panel(mapping_panel, "Open map file", MAPPING_OPEN_ID, controlBlock); //other details glui->add_separator(); glui->add_button("Open", OPEN_ID, controlBlock); glui->add_button("Save", SAVE_ID, controlBlock); glui->add_button("Reset", RESET_ID, controlBlock); glui->add_button("Quit", QUIT_ID, (GLUI_Update_CB)exit); /* register idle callback with GLUI, NOT with GLUT */ GLUI_Master.set_glutIdleFunc( handleIdle ); // handle when no events are occuring glutMainLoop(); // once this is called, glut takes over -- // returns only when the window is closed return EXIT_SUCCESS; }