Example #1
0
void initGLUI(int window) {
	GLUI *gluiSide = GLUI_Master.create_glui_subwindow(window, GLUI_SUBWINDOW_RIGHT);
	gluiSide->set_main_gfx_window(window);

	gluiSide->add_button("New Curve",     NEW_CURVE,   gluiHandler);

	gluiSide->add_button("New Surface",   NEW_SURFACE, gluiHandler);
	surfPanel = gluiSide->add_panel("Surface Parms", GLUI_PANEL_EMBOSSED);
	GLUI_Spinner *xS = gluiSide->add_spinner_to_panel(surfPanel, "X Pts.", 
									GLUI_SPINNER_INT, &surf_x, SURF_X, gluiHandler);
	xS->set_int_limits(3, 10);
	GLUI_Spinner *yS = gluiSide->add_spinner_to_panel(surfPanel, "Y Pts.", 
									GLUI_SPINNER_INT, &surf_y, SURF_Y, gluiHandler);
	yS->set_int_limits(3, 10);
	gluiSide->add_button_to_panel(surfPanel, "Ok", SURF_OK, gluiHandler);
	surfPanel->disable();

	gluiSide->add_button("Modify Points", MODIFY,      gluiHandler);
	gluiSide->add_button("Clear Screen",  CLEAR,       gluiHandler);
	gluiSide->add_button("Camera Mode",   CAMERA,      gluiHandler);

	gluiSide->add_separator();

	GLUI_Spinner *uS = gluiSide->add_spinner("U", GLUI_SPINNER_FLOAT, &u, U, gluiHandler);
	uS->set_float_limits(0.0f, 1.0f);
	uS->set_speed(50);
	GLUI_Spinner *vS = gluiSide->add_spinner("V", GLUI_SPINNER_FLOAT, &v, V, gluiHandler);
	vS->set_float_limits(0.0f, 1.0f);
	vS->set_speed(50);

	gluiSide->add_separator();

	gluiSide->add_button("Quit", QUIT, gluiHandler);
}
//############################################ Menu window functions ###############################################
void init_menu()
{
	GLUI_Master.close_all();						// Closes the previous windows
	GLUI *glui = GLUI_Master.create_glui( "RMS v1.0");
	glui->add_column(true);							// Adds a column separator
  	glui->add_statictext("WELCOME!");
  	glui->add_separator();							// Adds horizontal separator
  	glui->add_button("NEW USER",SET_NEW_USER,(GLUI_Update_CB)switcher_function);	// Adds a button 
  	glui->add_separator();
  	glui->add_button("OLD USER",SET_OLD_USER, (GLUI_Update_CB)switcher_function);
  	glui->add_separator();
  	glui->add_button("Quit",ERROR_CHECK,(GLUI_Update_CB)exit);
  	glui->add_separator();
  	glui->add_column(true);
}
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;
}
/**
 * @brief UI設定関数
 */
void setGlui(void)
{
  /* GLUIコントローラーの設定 */
  GLUI * glui = GLUI_Master.create_glui("Control Panel", 0);

  /* スリットサイズのテキストボックス追加 */
  GLUI_EditText * editSlitWidth = new GLUI_EditText(glui, "Slit width (cm)", &slitWidth, NULL, inputChangeSlitWidth);
  // 限界値とその処理
  //editSlitWidth->set_float_limits(0.0, 1.0, GLUI_LIMIT_CLAMP);
  // 初期値
  editSlitWidth->set_float_val(0.3);

  /* 移動スピードのテキストボックス追加 */
  GLUI_EditText * editSlitSpeed = new GLUI_EditText(glui, "Slit speed (cm)/s", &slitSpeed, NULL, inputChangeSlitSpeed);
  //editSlitSpeed->set_float_limits(0.0, 1.0, GLUI_LIMIT_CLAMP);
  editSlitSpeed->set_float_val(18000);

  // 仕切り線
  glui->add_separator();

  /* モード変更用のラジオボタン */
  // テキスト
  glui->add_statictext("Move select");
  GLUI_RadioGroup * mode_radio = new GLUI_RadioGroup(glui, &mode);
  // モード変更の項目設定
  glui->add_radiobutton_to_group(mode_radio, "Slit Move");
  glui->add_radiobutton_to_group(mode_radio, "Image Move");

  // 仕切り線
  glui->add_separator();

  // スリット色変え
  GLUI_RadioGroup * slit_mode_radio = new GLUI_RadioGroup(glui, &slitColor);
  glui->add_radiobutton_to_group(slit_mode_radio, "Black");
  glui->add_radiobutton_to_group(slit_mode_radio, "White");

  glui->add_separator();

  // 反復ボタン
  new GLUI_Checkbox(glui, "Repetition", &repetition);

  glui->add_separator();

  /* 画像変更のラジオボタン */
  glui->add_statictext("Image select");
  GLUI_RadioGroup * imageMode_radio = new GLUI_RadioGroup(glui, &ImageMode);
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Line drowing black");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Line drowing white");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Black");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - White");

  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Line drowing black");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Line drowing white");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Black");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - White");

  glui->add_radiobutton_to_group(imageMode_radio, "Momotaro");

  glui->add_radiobutton_to_group(imageMode_radio, "Circle");
  glui->add_radiobutton_to_group(imageMode_radio, "Square");
  glui->add_radiobutton_to_group(imageMode_radio, "triangle");

  // 仕切り線
  glui->add_separator();

  /* exitボタン */
  glui->add_button("Exit", 0, gluiCallBack);

  // idlezコールバック関数はGLUIで登録
  GLUI_Master.set_glutIdleFunc(NULL);
}
Example #5
0
int main(int argc, char **argv) {

    /* Seed random */
    srand(time(NULL));

    /* Init glut and glew */
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(X_SIZE, Y_SIZE);
    glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
    glutInitContextProfile(GLUT_CORE_PROFILE);
    glewExperimental = GL_TRUE;

    /* Create window */
    main_window = glutCreateWindow("Project");
    glewInit();
    glEnable(GL_DEPTH_TEST);

    /* Model init */
    Model::program_init();

    /* Data init */
    init();

    /* Glut functions */
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(special);
    glutIdleFunc(NULL);

    /* Glui */
    GLUI* glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_RIGHT);
    
    glui->set_main_gfx_window(main_window);

    glui->add_statictext("Camera Rotate");
    glui->add_separator();
    glui->add_button("X+", CAMERA_XPR, button_callback);
    glui->add_button("X-", CAMERA_XNR, button_callback);  
    glui->add_button("Y+", CAMERA_YPR, button_callback);
    glui->add_button("Y-", CAMERA_YNR, button_callback);
    glui->add_button("Z+", CAMERA_ZPR, button_callback);
    glui->add_button("Z-", CAMERA_ZNR, button_callback);

    glui->add_statictext("Camera Translate");
    glui->add_separator();
    glui->add_button("X+", CAMERA_XPT, button_callback);
    glui->add_button("X-", CAMERA_XNT, button_callback);  
    glui->add_button("Y+", CAMERA_YPT, button_callback);
    glui->add_button("Y-", CAMERA_YNT, button_callback);
    glui->add_button("Z+", CAMERA_ZPT, button_callback);
    glui->add_button("Z-", CAMERA_ZNT, button_callback);    

    glui->add_statictext("Light");
    glui->add_separator();
    glui->add_button("X+", LIGHT_XPT, button_callback);
    glui->add_button("X-", LIGHT_XNT, button_callback); 
    glui->add_button("Y+", LIGHT_YPT, button_callback);
    glui->add_button("Y-", LIGHT_YNT, button_callback);    
    glui->add_button("Z+", LIGHT_ZPT, button_callback);
    glui->add_button("Z-", LIGHT_ZNT, button_callback);   
    glui->add_button("Light+", LIGHTP, button_callback);
    glui->add_button("Light-", LIGHTN, button_callback);      

    glui->add_statictext("Materials");
    glui->add_separator();
    glui->add_button("Ambient+", AMBIENTP, button_callback);
    glui->add_button("Ambient-", AMBIENTN, button_callback); 
    glui->add_button("Diffuse+", DIFFUSEP, button_callback);
    glui->add_button("Diffuse-", DIFFUSEN, button_callback);    
    glui->add_button("Specular+", SPECULARP, button_callback);
    glui->add_button("Specular-", SPECULARN, button_callback);       
        
    GLUI_Master.set_glutIdleFunc(idle);

    /* Main loop */
    glutMainLoop();

    return 0;
}