void GLUI_List::scrollbar_callback(GLUI_Control *my_scrollbar) { GLUI_Scrollbar *sb = dynamic_cast<GLUI_Scrollbar*>(my_scrollbar); if (!sb) return; GLUI_List* me = (GLUI_List*) sb->associated_object; if (me->scrollbar == NULL) return; int new_start_line = sb->get_int_val(); // TODO!! me->start_line = new_start_line; if ( me->can_draw() ) me->update_and_draw_text(); }
void GLUI_TextBox::scrollbar_callback(GLUI_Control *my_scrollbar) { GLUI_Scrollbar *sb = dynamic_cast<GLUI_Scrollbar*>(my_scrollbar); if (!sb) return; GLUI_TextBox* me = (GLUI_TextBox*) sb->associated_object; if (me->scrollbar == NULL) return; int new_start_line = sb->get_int_val(); // ?? me->start_line = new_start_line; if (new_start_line < (me->curr_line - me->visible_lines)) me->curr_line = new_start_line + me->visible_lines; if (new_start_line > me->curr_line) me->curr_line = new_start_line; if ( me->can_draw() ) me->update_and_draw_text(); }
int main(int argc, char* argv[]) { /****************************************/ /* Initialize GLUT and create window */ /****************************************/ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowPosition(80, 80); glutInitWindowSize(windowWidth, windowHeight); int main_window = glutCreateWindow("Rendering Test"); glewInit(); glutDisplayFunc(myGlutDisplay); glutMotionFunc(myGlutMotion); glutReshapeFunc(myGlutReshape); glutPassiveMotionFunc(myGlutPassiveMotion); glutMouseWheelFunc(myGlutMouseWheel); glutMouseFunc(myGlutMouse); glutKeyboardFunc(myGlutKeyboard); glEnable(GL_DEPTH_TEST); /****************************************/ /* Here's the GLSL code */ /****************************************/ geomFb.AddExtraDrawTexture(GL_RGBA32F, GL_RGBA, GL_FLOAT, GL_NEAREST, GL_CLAMP_TO_EDGE); geomFb.AddExtraDrawTexture(GL_RGBA32F, GL_RGBA, GL_FLOAT, GL_NEAREST, GL_CLAMP_TO_EDGE); glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE); glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE); glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); /****************************************/ /* Loading Data */ /****************************************/ ssaoPass.Build(); blurPass.Build(); lightingPass.Build(); #ifdef TRACK trackBall.SetRotationMatrix(MyMatrixf::RotateMatrix(90, 1, 0, 0)); trackBall.ScaleMultiply(1.3); MyTracks tractData; MyBitmap bitmap; bitmap.Open("..\\SSAO\\data\\diverging.bmp"); gTex = MyTexture::MakeGLTexture(&bitmap); //tractData.Read("data\\normal_s3.data"); tractData.Read("C:\\Users\\GuohaoZhang\\Dropbox\\data\\normal_s4.tensorinfo"); tractData.AppendTrackColor("C:\\Users\\GuohaoZhang\\Dropbox\\data\\normal_s4_boy.data"); tractData.Save("C:\\Users\\GuohaoZhang\\Dropbox\\data\\normal_s4_tensorboy.trk"); return 1; tractData.Read("C:\\Users\\GuohaoZhang\\Dropbox\\data\\normal_s3_tensorboy_RevZ.trk"); //tractData.Read("data\\normal_s5.tensorinfo"); //tractData.Read("data\\normal_s5_2pt.tensorinfo"); //tractData.Read("data\\cFile.tensorinfo"); //tractData.Read("C:\\Users\\GuohaoZhang\\Desktop\\tmpdata\\dti.trk"); //tractData.Read("C:\\Users\\GuohaoZhang\\Desktop\\tmpdata\\ACR.trk"); //tractData.Read("dti_20_0995.data"); track.SetTracts(&tractData); track.SetTexture(gTex); //track.SetShape(MyTractVisBase::TRACK_SHAPE_LINE); track.SetShape(MyTractVisBase::TrackShape(trackShape + 1)); track.ComputeGeometry(); track.LoadShader(); track.LoadGeometry(); trackLine.SetTracts(&tractData); trackLine.SetShape(MyTractVisBase::TRACK_SHAPE_LINE); trackLine.ComputeGeometry(); trackLine.LoadShader(); trackLine.LoadGeometry(); track.SetToInfluence(tractEncoding); MyVec3f center = track.GetTracts()->GetBoundingBox().GetCenter(); cout << "Center: " << center[0] << ", " << center[1] << ", " << center[2] << endl; #endif #ifdef MESH gTex = MakeTexture("2dir_128.bmp"); meshPrecision = 0.01; //mesh.Read("data\\lh.trans.pial.obj"); mesh.Read("data\\lh.pial.DK.fusiform_trans.obj"); //mesh.Read("lh.pial.obj"); //mesh.Read("data\\lh.trans.pial.obj"); //MyMesh mesh2; //mesh2.Read("data\\rh.trans.pial.obj"); //mesh.Merge(mesh2); mesh.MergeVertices(meshPrecision); mesh.GenPerVertexNormal(); //mesh.Write("data\\rh.trans_wnormal.pial.obj"); mesh.CompileShader(); mesh.mTexture = gTex; mesh.Build(); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #endif /****************************************/ /* Here's the GLUI code */ /****************************************/ printf("GLUI version: %3.2f\n", GLUI_Master.get_version()); GLUI_Master.set_glutDisplayFunc(myGlutDisplay); GLUI_Master.set_glutReshapeFunc(myGlutReshape); GLUI_Master.set_glutKeyboardFunc(myGlutKeyboard); GLUI_Master.set_glutSpecialFunc(NULL); GLUI_Master.set_glutMouseFunc(myGlutMouse); glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_RIGHT); glui->set_main_gfx_window(main_window); // add panels for parameter tunning panel[0] = new GLUI_Panel(glui, "Rendering Mode"); GLUI_Spinner* dsrSpinner = new GLUI_Spinner( panel[0], "DSR Index", GLUI_SPINNER_INT, &dsrIndex, -1, changeDsr); dsrSpinner->set_int_limits(1, 4); GLUI_RadioGroup* radioGroup = new GLUI_RadioGroup(panel[0], &renderIdx, 0, switchRenderMode); new GLUI_RadioButton(radioGroup, "Geometry Pass"); new GLUI_RadioButton(radioGroup, "SSAO Pass"); new GLUI_RadioButton(radioGroup, "Blur Pass"); new GLUI_RadioButton(radioGroup, "Lighting Pass"); new GLUI_Button(panel[0], "Reset All", -1, resetRenderingParameters); new GLUI_Button(panel[0], "Reset Shaders", -1, resetShaders); // geometry pass panel[1] = new GLUI_Panel(glui, "Geometry Pass"); new GLUI_Button(panel[1], "Reset", 0, resetRenderingParameters); new GLUI_Checkbox(panel[1], "Cull Backface", &cullface, -1, changeCullface); new GLUI_Checkbox(panel[1], "Draw Tracts", &bdrawTracks, -1, reRender); new GLUI_Checkbox(panel[1], "Draw Axes", &bdrawAxes, -1, reRender); #ifdef MESH GLUI_Spinner* meshPrecisionSpinner = new GLUI_Spinner (panel[1], "Mesh Detail", GLUI_SPINNER_FLOAT, &meshPrecision, -1, changeMeshPrecision); meshPrecisionSpinner->set_float_limits(0.01, 10); #endif #ifdef TRACK GLUI_RadioGroup* shapeRadioGroup = new GLUI_RadioGroup(panel[1], &trackShape, 0, changeTrackShape); new GLUI_RadioButton(shapeRadioGroup, "Line"); new GLUI_RadioButton(shapeRadioGroup, "Tube"); new GLUI_RadioButton(shapeRadioGroup, "Superquadric"); GLUI_RadioGroup* encodingRadioGroup = new GLUI_RadioGroup(panel[1], &tractEncoding, 0, changeTractEncoding); new GLUI_RadioButton(encodingRadioGroup, "Boy's"); new GLUI_RadioButton(encodingRadioGroup, "Color"); new GLUI_RadioButton(encodingRadioGroup, "Size"); new GLUI_RadioButton(encodingRadioGroup, "Texture"); tubeParameterPanel = new GLUI_Panel(panel[1], "Tube Parameters"); new GLUI_StaticText(tubeParameterPanel, "Tube Radius"); GLUI_Scrollbar* tubeRadiusSlider = new GLUI_Scrollbar (tubeParameterPanel, "Tube Radius", GLUI_SCROLL_HORIZONTAL, &(track.mTrackRadius), -1, reRender); tubeRadiusSlider->set_float_limits(0, 1); GLUI_Spinner* boxOpacitySpinner = new GLUI_Spinner( tubeParameterPanel, "Opacity Index", GLUI_SPINNER_INT, &boxOpacityIndex, -1, reRender); boxOpacitySpinner->set_int_limits(0, 2); GLUI_Spinner* trackFaceSpinner = new GLUI_Spinner( tubeParameterPanel, "Number Faces", GLUI_SPINNER_INT, &trackFaces, -1, changeTrackShape); trackFaceSpinner->set_int_limits(2, 20); trackFaceSpinner->set_int_val(track.GetNumberFaces()); #endif // ssao pass panel[2] = new GLUI_Panel(glui, "SSAO Pass"); new GLUI_Button(panel[2], "Reset", 1, resetRenderingParameters); new GLUI_StaticText(panel[2], "Sample Radius"); GLUI_Scrollbar* sampleRadiusSlider = new GLUI_Scrollbar (panel[2], "Sample Radius", GLUI_SCROLL_HORIZONTAL, &(ssaoPass.mSampleRadius), -1, reRender); sampleRadiusSlider->set_float_limits(0, 100); new GLUI_StaticText(panel[2], "Occlusion Power"); GLUI_Scrollbar* occulusioPowerSlider = new GLUI_Scrollbar (panel[2], "Occlusion Power", GLUI_SCROLL_HORIZONTAL, &(ssaoPass.mOcclusionPower), -1, reRender); occulusioPowerSlider->set_float_limits(0, 4); // blur pass panel[3] = new GLUI_Panel(glui, "Blur Pass"); new GLUI_Button(panel[3], "Reset", 2, resetRenderingParameters); GLUI_Spinner* blurRadiusSpinner = new GLUI_Spinner (panel[3], "Blur Radius (Pixel)", GLUI_SPINNER_INT, &(blurPass.mBlurRadius), -1, reRender); blurRadiusSpinner->set_int_limits(0, 20); // lighting pass lightingPass.mAmbient = 0.4; lightingPass.mDiffuse = 0.6; lightingPass.mSpecular = 0; lightingPass.mUseSsao = 1; panel[4] = new GLUI_Panel(glui, "Lighting Pass"); new GLUI_Button(panel[4], "Reset", 3, resetRenderingParameters); new GLUI_Checkbox(panel[4], "Normalize Intensity", &lightComponentRatioControl, -1, changeLightComponent); new GLUI_Checkbox(panel[4], "Use SSAO", &lightingPass.mUseSsao, -1, changeLightComponent); new GLUI_StaticText(panel[4], "Light Intensity"); GLUI_Scrollbar* lightIntensitySlider = new GLUI_Scrollbar (panel[4], "Light Intensity", GLUI_SCROLL_HORIZONTAL, &(lightingPass.mLightItensity), -1, reRender); lightIntensitySlider->set_float_limits(0, 10); new GLUI_StaticText(panel[4], "Ambient"); lightComponentSlider[0] = new GLUI_Scrollbar (panel[4], "Ambient", GLUI_SCROLL_HORIZONTAL, &(lightingPass.mAmbient), 0, changeLightComponent); lightComponentSlider[0]->set_float_limits(0, 1); new GLUI_StaticText(panel[4], "Diffuse"); lightComponentSlider[1] = new GLUI_Scrollbar (panel[4], "Diffuse", GLUI_SCROLL_HORIZONTAL, &(lightingPass.mDiffuse), 1, changeLightComponent); lightComponentSlider[1]->set_float_limits(0, 1); new GLUI_StaticText(panel[4], "Specular"); lightComponentSlider[2] = new GLUI_Scrollbar (panel[4], "Specular", GLUI_SCROLL_HORIZONTAL, &(lightingPass.mSpecular), 2, changeLightComponent); lightComponentSlider[2]->set_float_limits(0, 1); new GLUI_StaticText(panel[4], "Shininess"); GLUI_Scrollbar* shininessSlider = new GLUI_Scrollbar (panel[4], "Shininess", GLUI_SCROLL_HORIZONTAL, &(lightingPass.mShininess), -1, changeLightComponent); shininessSlider->set_float_limits(0, 128); // set init state right switchRenderMode(renderIdx); glutMainLoop(); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { /****************************************/ /* Initialize GLUT and create window */ /****************************************/ glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); glutInitWindowSize( 800, 600 ); main_window = glutCreateWindow( "GLUI Example 5" ); glutDisplayFunc( myGlutDisplay ); GLUI_Master.set_glutReshapeFunc( myGlutReshape ); GLUI_Master.set_glutKeyboardFunc( myGlutKeyboard ); GLUI_Master.set_glutSpecialFunc( NULL ); GLUI_Master.set_glutMouseFunc( myGlutMouse ); glutMotionFunc( myGlutMotion ); /****************************************/ /* Set up OpenGL lights */ /****************************************/ glEnable(GL_LIGHTING); glEnable( GL_NORMALIZE ); 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_LIGHT1); glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); /****************************************/ /* Enable z-buferring */ /****************************************/ glEnable(GL_DEPTH_TEST); /****************************************/ /* Here's the GLUI code */ /****************************************/ printf( "GLUI version: %3.2f\n", GLUI_Master.get_version() ); /*** Create the side subwindow ***/ glui = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_RIGHT ); obj_panel = new GLUI_Rollout(glui, "Properties", false ); /***** Control for object params *****/ new GLUI_Checkbox( obj_panel, "Wireframe", &wireframe, 1, control_cb ); GLUI_Spinner *spinner = new GLUI_Spinner( obj_panel, "Segments:", &segments); spinner->set_int_limits( 3, 60 ); spinner->set_alignment( GLUI_ALIGN_RIGHT ); GLUI_Spinner *scale_spinner = new GLUI_Spinner( obj_panel, "Scale:", &scale); scale_spinner->set_float_limits( .2f, 4.0 ); scale_spinner->set_alignment( GLUI_ALIGN_RIGHT ); /******** Add some controls for lights ********/ GLUI_Rollout *roll_lights = new GLUI_Rollout(glui, "Lights", false ); GLUI_Panel *light0 = new GLUI_Panel( roll_lights, "Light 1" ); GLUI_Panel *light1 = new GLUI_Panel( roll_lights, "Light 2" ); new GLUI_Checkbox( light0, "Enabled", &light0_enabled, LIGHT0_ENABLED_ID, control_cb ); light0_spinner = new GLUI_Spinner( light0, "Intensity:", &light0_intensity, LIGHT0_INTENSITY_ID, control_cb ); light0_spinner->set_float_limits( 0.0, 1.0 ); GLUI_Scrollbar *sb; sb = new GLUI_Scrollbar( light0, "Red",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[0],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Green",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[1],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Blue",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[2],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); new GLUI_Checkbox( light1, "Enabled", &light1_enabled, LIGHT1_ENABLED_ID, control_cb ); light1_spinner = new GLUI_Spinner( light1, "Intensity:", &light1_intensity, LIGHT1_INTENSITY_ID, control_cb ); light1_spinner->set_float_limits( 0.0, 1.0 ); sb = new GLUI_Scrollbar( light1, "Red",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[0],LIGHT1_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light1, "Green",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[1],LIGHT1_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light1, "Blue",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[2],LIGHT1_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); /*** Add another rollout ***/ GLUI_Rollout *options = new GLUI_Rollout(glui, "Options", true ); new GLUI_Checkbox( options, "Draw sphere", &show_sphere ); new GLUI_Checkbox( options, "Draw torus", &show_torus ); new GLUI_Checkbox( options, "Draw axes", &show_axes ); new GLUI_Checkbox( options, "Draw text", &show_text ); /**** Add listbox ****/ new GLUI_StaticText( glui, "" ); GLUI_Listbox *list = new GLUI_Listbox( glui, "Text:", &curr_string ); int i; for( i=0; i<4; i++ ) list->add_item( i, string_list[i] ); new GLUI_StaticText( glui, "" ); /*** Disable/Enable buttons ***/ new GLUI_Button( glui, "Disable movement", DISABLE_ID, control_cb ); new GLUI_Button( glui, "Enable movement", ENABLE_ID, control_cb ); new GLUI_Button( glui, "Hide", HIDE_ID, control_cb ); new GLUI_Button( glui, "Show", SHOW_ID, control_cb ); new GLUI_StaticText( glui, "" ); /****** A 'quit' button *****/ new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit ); /**** Link windows to GLUI, and register idle callback ******/ glui->set_main_gfx_window( main_window ); /*** Create the bottom subwindow ***/ glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM ); glui2->set_main_gfx_window( main_window ); GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "Objects", view_rotate ); view_rot->set_spin( 1.0 ); new GLUI_Column( glui2, false ); GLUI_Rotation *sph_rot = new GLUI_Rotation(glui2, "Sphere", sphere_rotate ); sph_rot->set_spin( .98 ); new GLUI_Column( glui2, false ); GLUI_Rotation *tor_rot = new GLUI_Rotation(glui2, "Torus", torus_rotate ); tor_rot->set_spin( .98 ); new GLUI_Column( glui2, false ); GLUI_Rotation *lights_rot = new GLUI_Rotation(glui2, "Blue Light", lights_rotation ); lights_rot->set_spin( .82 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_xy = new GLUI_Translation(glui2, "Objects XY", GLUI_TRANSLATION_XY, obj_pos ); trans_xy->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_x = new GLUI_Translation(glui2, "Objects X", GLUI_TRANSLATION_X, obj_pos ); trans_x->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_y = new GLUI_Translation( glui2, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] ); trans_y->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_z = new GLUI_Translation( glui2, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] ); trans_z->set_speed( .005 ); #if 0 /**** We register the idle callback with GLUI, *not* with GLUT ****/ GLUI_Master.set_glutIdleFunc( myGlutIdle ); #endif /**** Regular GLUT main loop ****/ glutMainLoop(); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { /****************************************/ /* Initialize GLUT and create window */ /****************************************/ glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); glutInitWindowSize( 800, 600 ); main_window = glutCreateWindow( "User Interaction - InClass Assignment 2" ); glutDisplayFunc( myGlutDisplay ); GLUI_Master.set_glutReshapeFunc( myGlutReshape ); GLUI_Master.set_glutKeyboardFunc( myGlutKeyboard ); GLUI_Master.set_glutSpecialFunc( NULL ); GLUI_Master.set_glutMouseFunc( myGlutMouse ); glutMotionFunc( myGlutMotion ); /****************************************/ /* Set up OpenGL lights */ /****************************************/ // Essentially set the background color of the 3D scene. glClearColor(0.1, 0.1, 0.1, 1.0); glShadeModel(GL_FLAT); GLfloat light_pos0[] = { 0.0f, 0.0f, 1.0f, 0.0f }; GLfloat diffuse[] = { 0.5f, 0.5f, 0.5f, 0.0f }; GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light_pos0); //glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); /****************************************/ /* Enable z-buferring */ /****************************************/ glEnable(GL_DEPTH_TEST); glPolygonOffset(1, 1); /****************************************/ /* Here's the GLUI code */ /****************************************/ /* Implement functionality here Spend some time */ /*** Create the side subwindow ***/ glui = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_RIGHT ); obj_panel = new GLUI_Rollout(glui, "Properties", true ); /***** Control for object params *****/ new GLUI_Checkbox( obj_panel, "Wireframe", &wireframe, 1, control_cb ); GLUI_Spinner *zoom_spinner = new GLUI_Spinner( obj_panel, "Zoom:", &zoom); zoom_spinner->set_float_limits( .2f, 4.0 ); zoom_spinner->set_alignment( GLUI_ALIGN_RIGHT ); /******** Add some controls for lights ********/ GLUI_Rollout *roll_lights = new GLUI_Rollout(glui, "Lights", false ); GLUI_Panel *light0 = new GLUI_Panel( roll_lights, "Light 0" ); new GLUI_Checkbox( light0, "Enabled", &light0_enabled, LIGHT0_ENABLED_ID, control_cb ); light0_spinner = new GLUI_Spinner( light0, "Intensity:", &light0_intensity, LIGHT0_INTENSITY_ID, control_cb ); light0_spinner->set_float_limits( 0.0, 1.0 ); GLUI_Scrollbar *sb; sb = new GLUI_Scrollbar( light0, "Red",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[0],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Green",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[1],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Blue",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[2],LIGHT0_INTENSITY_ID,control_cb); sb->set_float_limits(0,1); /*** Change color ***/ GLUI_Rollout* colors = new GLUI_Rollout(glui, "Colors", false); GLUI_Scrollbar *csb; csb = new GLUI_Scrollbar( colors, "Red",GLUI_SCROLL_HORIZONTAL, &color[0],CHANGE_COLOR,control_cb); csb->set_float_limits(0, 1); csb = new GLUI_Scrollbar( colors, "Green",GLUI_SCROLL_HORIZONTAL, &color[1],CHANGE_COLOR,control_cb); csb->set_float_limits(0, 1); csb = new GLUI_Scrollbar( colors, "Blue",GLUI_SCROLL_HORIZONTAL, &color[2],CHANGE_COLOR,control_cb); csb->set_float_limits(0, 1); /*** Add another rollout ***/ GLUI_Rollout *options = new GLUI_Rollout(glui, "Options", true ); new GLUI_Checkbox( options, "Draw PLY", &show_ply ); new GLUI_Checkbox( options, "Draw Axes and Grid", &show_axes ); /*** Disable/Enable buttons ***/ new GLUI_Button( glui, "Disable movement", DISABLE_ID, control_cb ); new GLUI_Button( glui, "Enable movement", ENABLE_ID, control_cb ); new GLUI_StaticText( glui, "" ); /****** A 'quit' button *****/ new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit ); /**** Link windows to GLUI, and register idle callback ******/ glui->set_main_gfx_window( main_window ); /*** Create the bottom subwindow ***/ glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM ); glui2->set_main_gfx_window( main_window ); GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "View", view_rotate ); view_rot->set_spin( 1.0 ); new GLUI_Column( glui2, false ); new GLUI_Column( glui2, false ); GLUI_Rotation *tor_rot = new GLUI_Rotation(glui2, "PLY", ply_rotate ); tor_rot->set_spin( .98 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_xy = new GLUI_Translation(glui2, "Object XY", GLUI_TRANSLATION_XY, obj_pos ); trans_xy->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_x = new GLUI_Translation(glui2, "Object X", GLUI_TRANSLATION_X, obj_pos ); trans_x->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_y = new GLUI_Translation( glui2, "Object Y", GLUI_TRANSLATION_Y, &obj_pos[1] ); trans_y->set_speed( .005 ); new GLUI_Column( glui2, false ); GLUI_Translation *trans_z = new GLUI_Translation( glui2, "Object Z", GLUI_TRANSLATION_Z, &obj_pos[2] ); trans_z->set_speed( .005 ); #if 0 /**** We register the idle callback with GLUI, *not* with GLUT ****/ GLUI_Master.set_glutIdleFunc( myGlutIdle ); #endif // Load our model myPLY = new ply("./bunny.ply"); /**** Regular GLUT main loop ****/ glutMainLoop(); return EXIT_SUCCESS; }
// initialize GLUI int MeshGui::initGlui(void) { // create the side subwindow GLUI *glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_RIGHT); // radio button group GLUI_RadioGroup *ot_group = new GLUI_RadioGroup (glui, &radiogroup_item_id, SHADING_MODE, control_cb); // shading choices glui->add_radiobutton_to_group( ot_group, "flatShaded" ); glui->add_radiobutton_to_group( ot_group, "smoothShaded" ); glui->add_radiobutton_to_group( ot_group, "wireframe" ); glui->add_radiobutton_to_group( ot_group, "shadedEdges" ); glui->add_radiobutton_to_group( ot_group, "point" ); // load and save smf file new GLUI_EditText (glui, "smf/", GLUI_EDITTEXT_TEXT, filetext, INPUT_FILE, control_cb); new GLUI_Button( glui, "open", OPEN_MESH, control_cb ); new GLUI_Button( glui, "save", SAVE_MESH, control_cb ); // A 'quit' button new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit ); // some controls for lights //GLUI_Rollout *roll_lights = new GLUI_Rollout(glui, "Lights", false); GLUI_Panel *light0 = new GLUI_Panel( glui, "Light 0" ); GLUI_Panel *light1 = new GLUI_Panel( glui, "Light 1" ); new GLUI_Checkbox( light0, "Enabled", &light0_enabled, LIGHT0_ENABLE, control_cb ); light0_spinner = new GLUI_Spinner( light0, "Intensity:", &light0_intensity, LIGHT0_INTENSITY, control_cb ); light0_spinner->set_float_limits( 0.0, 1.0 ); GLUI_Scrollbar *sb; sb = new GLUI_Scrollbar( light0, "Red",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[0],LIGHT0_INTENSITY,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Green",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[1],LIGHT0_INTENSITY,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light0, "Blue",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[2],LIGHT0_INTENSITY,control_cb); sb->set_float_limits(0,1); new GLUI_Checkbox( light1, "Enabled", &light1_enabled, LIGHT1_ENABLE, control_cb ); light1_spinner = new GLUI_Spinner( light1, "Intensity:", &light1_intensity, LIGHT1_INTENSITY, control_cb ); light1_spinner->set_float_limits( 0.0, 1.0 ); sb = new GLUI_Scrollbar( light1, "Red",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[0],LIGHT1_INTENSITY,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light1, "Green",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[1],LIGHT1_INTENSITY,control_cb); sb->set_float_limits(0,1); sb = new GLUI_Scrollbar( light1, "Blue",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[2],LIGHT1_INTENSITY,control_cb); sb->set_float_limits(0,1); // edge number to randomly choose from GLUI_Spinner *edge_spinner = new GLUI_Spinner(glui, "EdgeNumber", &edge_number, EDGE_NUMBER, control_cb ); edge_spinner->set_float_limits(2, 100); // edge percentage to collapse GLUI_Spinner *percentage_spinner = new GLUI_Spinner(glui, "CollapsePercentage%", &collapse_percentage, COLLAPSE_NUMBER, control_cb ); percentage_spinner->set_float_limits(1, 100); new GLUI_Button(glui, "decimate", DECIMATE, control_cb ); // Link windows to GLUI, and register idle callback glui->set_main_gfx_window( main_window ); // Create the bottom subwindow GLUI *glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM ); glui2->set_main_gfx_window( main_window ); // rotate the world GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "Objects", view_rotate ); view_rot->set_spin( 1.0 ); // rotate the model new GLUI_Column( glui2, false ); GLUI_Rotation *sph_rot = new GLUI_Rotation(glui2, "Model", mesh_rotate ); sph_rot->set_spin( .98 ); // rotate the blue light new GLUI_Column( glui2, false ); GLUI_Rotation *lights_rot = new GLUI_Rotation(glui2, "Blue Light", lights_rotation ); lights_rot->set_spin( .82 ); // object XY translate new GLUI_Column( glui2, false ); GLUI_Translation *trans_xy = new GLUI_Translation(glui2, "Objects XY", GLUI_TRANSLATION_XY, obj_pos ); trans_xy->set_speed( .005 ); // object X translate new GLUI_Column( glui2, false ); GLUI_Translation *trans_x = new GLUI_Translation(glui2, "Objects X", GLUI_TRANSLATION_X, obj_pos ); trans_x->set_speed( .005 ); // object Y translate new GLUI_Column( glui2, false ); GLUI_Translation *trans_y = new GLUI_Translation( glui2, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] ); trans_y->set_speed( .005 ); // object y translate new GLUI_Column( glui2, false ); GLUI_Translation *trans_z = new GLUI_Translation( glui2, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] ); trans_z->set_speed( .005 ); return EXIT_SUCCESS; }