Exemplo n.º 1
0
void TPinterface::initGUI()
{
	// Check CGFinterface.h and GLUI documentation for the types of controls available
	//GLUI_Panel *varPanel= addPanel("Group", 1);
	//addSpinnerToPanel(varPanel, "Val 1(interface)", 2, &testVar, 1);

	// You could also pass a reference to a variable from the scene class, if public
	//addSpinnerToPanel(varPanel, "Val 2(scene)", 2, &(((LightingScene*) scene)->sceneVar), 2);
	//addColumn ();
	GLUI_Panel *varLuz= addPanel("Luzes", 2);
	addCheckboxToPanel(varLuz, "Luz 1",&((LightingScene *) scene)->state1,NULL);
	addCheckboxToPanel(varLuz, "Luz 2",&((LightingScene *) scene)->state2,NULL);
	addCheckboxToPanel(varLuz, "Luz 3",&((LightingScene *) scene)->state3,NULL);
	addCheckboxToPanel(varLuz, "Luz 4",&((LightingScene *) scene)->state4,NULL);
	addColumn ();
	GLUI_Panel *varClock= addPanel("Relogio", 3);
	addStaticText("Relógio");
	addButton ("Pause/Start",1);
	addColumn ();
	GLUI_Panel *vartext= addPanel("Texturas",4);
	GLUI_Listbox *textvar =addListboxToPanel(vartext,"Texturas",&((LightingScene *) scene)->statetext,NULL);
	textvar->add_item (1, "Default");
	textvar->add_item (2, "Sky");
	textvar->add_item (3, "Space");
	textvar->set_int_val (3); 
	addColumn();
	GLUI_Panel *varwire= addPanel("Wireframe",5);
	GLUI_RadioGroup *group=addRadioGroupToPanel(varwire,&((LightingScene *) scene)->wire);
	addRadioButtonToGroup(group,"Normal");
	addRadioButtonToGroup(group,"Wireframe");
	addColumn();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);  
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);

	main_window = glutCreateWindow("OBJ Loader");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);  
	glutMouseFunc(myGlutMouse);
	glutMotionFunc(myGlutMotion);

	initScene();
	Objects.push_back(Object());

	glui = GLUI_Master.create_glui("OBJ Loader GUI", 0, 600, 50);

	GLUI_Panel *objPanel = glui->add_panel("");
	GLUI_Panel *objPanel2 = glui->add_panel_to_panel(objPanel, "", 0);
	objFileNameTextField = glui->add_edittext_to_panel(objPanel2, "Filename:",GLUI_EDITTEXT_TEXT,NULL,OBJ_TEXTFIELD,textCB);
	objFileNameTextField->set_text("cow");
	glui->add_button_to_panel(objPanel2, "Load", LOAD_BUTTON, buttonCB);
	glui->add_button_to_panel(objPanel2, "Screenshot (or it didn't happen)", SCREENSHOT, buttonCB);

	glui->add_column_to_panel(objPanel, 0);

	GLUI_Panel *projPanel = glui->add_panel_to_panel(objPanel, "", 0);
	GLUI_RadioGroup *projGroup = glui->add_radiogroup_to_panel(projPanel, (int*) &projType, -1, projCB);
	glui->add_radiobutton_to_group(projGroup, "Orthographic");
	glui->add_radiobutton_to_group(projGroup, "Perspective");
	projGroup->set_int_val(ORTHO);

	GLUI_Spinner *fovSpinner = glui->add_spinner_to_panel(projPanel, "FOV", GLUI_SPINNER_INT, &fov, FOV, projCB);
	fovSpinner->set_int_limits(FOVMIN, FOVMAX);
	fovSpinner->set_int_val(30);

	glui->add_column_to_panel(projPanel, 0);

	GLUI_Translation *scale = glui->add_translation_to_panel(projPanel, "Scale", GLUI_TRANSLATION_Y , &scaleFactor, -1, (GLUI_Update_CB) projCB);
	scale->set_speed(0.005f);

	GLUI_Panel *lightingPanel = glui->add_panel("", 0);

	GLUI_Panel *objMaterialPanel = glui->add_panel_to_panel(lightingPanel, "Object material");

	GLUI_Panel *objDiffusePanel = glui->add_panel_to_panel(objMaterialPanel, "Diffuse");
	GLUI_Spinner *kdRedValue = glui->add_spinner_to_panel(objDiffusePanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.diffuse[0], 0, colorCB);
	kdRedValue->set_float_limits(0.f, 1.f);
	kdRedValue->set_float_val(1.f);
	GLUI_Spinner *kdGreenValue = glui->add_spinner_to_panel(objDiffusePanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.diffuse[1], 0, colorCB);
	kdGreenValue->set_float_limits(0.f, 1.f);
	kdGreenValue->set_float_val(1.f);
	GLUI_Spinner *kdBlueValue = glui->add_spinner_to_panel(objDiffusePanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.diffuse[2], 0, colorCB);
	kdBlueValue->set_float_limits(0.f, 1.f);
	kdBlueValue->set_float_val(1.f);

	GLUI_Panel *objAmbientPanel = glui->add_panel_to_panel(objMaterialPanel, "Ambient");
	GLUI_Spinner *kaRedValue = glui->add_spinner_to_panel(objAmbientPanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.ambient[0], 0, colorCB);
	kaRedValue->set_float_limits(0.f, 1.f);
	kaRedValue->set_float_val(1.f);
	GLUI_Spinner *kaGreenValue = glui->add_spinner_to_panel(objAmbientPanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.ambient[1], 0, colorCB);
	kaGreenValue->set_float_limits(0.f, 1.f);
	kaGreenValue->set_float_val(1.f);
	GLUI_Spinner *kaBlueValue = glui->add_spinner_to_panel(objAmbientPanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.ambient[2], 0, colorCB);
	kaBlueValue->set_float_limits(0.f, 1.f);
	kaBlueValue->set_float_val(1.f);

	GLUI_Panel *objSpecularPanel = glui->add_panel_to_panel(objMaterialPanel, "Specular");
	GLUI_Spinner *ksRedValue = glui->add_spinner_to_panel(objSpecularPanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.specular[0], 0, colorCB);
	ksRedValue->set_float_limits(0.f, 1.f);
	ksRedValue->set_float_val(1.f);
	GLUI_Spinner *ksGreenValue = glui->add_spinner_to_panel(objSpecularPanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.specular[1], 0, colorCB);
	ksGreenValue->set_float_limits(0.f, 1.f);
	ksGreenValue->set_float_val(1.f);
	GLUI_Spinner *ksBlueValue = glui->add_spinner_to_panel(objSpecularPanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.specular[2], 0, colorCB);
	ksBlueValue->set_float_limits(0.f, 1.f);
	ksBlueValue->set_float_val(1.f);

	glui->add_column_to_panel(lightingPanel,0);
	GLUI_Panel *lightPanel = glui->add_panel_to_panel(lightingPanel, "Light source");

	GLUI_Panel *lightDiffusePanel = glui->add_panel_to_panel(lightPanel, "Diffuse");
	GLUI_Spinner *ldRedValue = glui->add_spinner_to_panel(lightDiffusePanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[0], -1, colorCB);
	ldRedValue->set_float_limits(0.f, 1.f);
	ldRedValue->set_float_val(1.f);
	GLUI_Spinner *ldGreenValue = glui->add_spinner_to_panel(lightDiffusePanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[1], -1, colorCB);
	ldGreenValue->set_float_limits(0.f, 1.f);
	ldGreenValue->set_float_val(1.f);
	GLUI_Spinner *ldBlueValue = glui->add_spinner_to_panel(lightDiffusePanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[2], -1, colorCB);
	ldBlueValue->set_float_limits(0.f, 1.f);
	ldBlueValue->set_float_val(1.f);

	GLUI_Panel *lightAmbientPanel = glui->add_panel_to_panel(lightPanel, "Ambient");
	GLUI_Spinner *laRedValue = glui->add_spinner_to_panel(lightAmbientPanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[0], -1, colorCB);
	laRedValue->set_float_limits(0.f, 1.f);
	laRedValue->set_float_val(1.f);
	GLUI_Spinner *laGreenValue = glui->add_spinner_to_panel(lightAmbientPanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[1], -1, colorCB);
	laGreenValue->set_float_limits(0.f, 1.f);
	laGreenValue->set_float_val(1.f);
	GLUI_Spinner *laBlueValue = glui->add_spinner_to_panel(lightAmbientPanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[2], -1, colorCB);
	laBlueValue->set_float_limits(0.f, 1.f);
	laBlueValue->set_float_val(1.f);

	GLUI_Panel *lightSpecularPanel = glui->add_panel_to_panel(lightPanel, "Specular");
	GLUI_Spinner *lsRedValue = glui->add_spinner_to_panel(lightSpecularPanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[0], -1, colorCB);
	lsRedValue->set_float_limits(0.f, 1.f);
	lsRedValue->set_float_val(1.f);
	GLUI_Spinner *lsGreenValue = glui->add_spinner_to_panel(lightSpecularPanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[1], -1, colorCB);
	lsGreenValue->set_float_limits(0.f, 1.f);
	lsGreenValue->set_float_val(1.f);
	GLUI_Spinner *lsBlueValue = glui->add_spinner_to_panel(lightSpecularPanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[2], -1, colorCB);
	lsBlueValue->set_float_limits(0.f, 1.f);
	lsBlueValue->set_float_val(1.f);

	GLUI_Panel *texturingPanel = glui->add_panel("Texturing");
	GLUI_Listbox *textureListbox = glui->add_listbox_to_panel(texturingPanel, "Texture", (int*)&texture, -1, textureCB);
	textureListbox->add_item(NOTEXTURE, "No texture");
	textureListbox->add_item(OSU, "OSU");
	textureListbox->add_item(EARTH, "EARTH");
	textureListbox->add_item(WOOD, "WOOD");
	textureListbox->set_int_val(NOTEXTURE);

	GLUI_Panel *texFiltersPanel = glui->add_panel_to_panel(texturingPanel, "", 0);
	GLUI_Panel *minFilterPanel = glui->add_panel_to_panel(texFiltersPanel, "Minifying filter", 1);
	GLUI_RadioGroup *minFilterGroup = glui->add_radiogroup_to_panel(minFilterPanel, (int*) &texMinFilter, -1, textureCB);
	glui->add_radiobutton_to_group(minFilterGroup, "Linear");
	glui->add_radiobutton_to_group(minFilterGroup, "Nearest");
	minFilterGroup->set_int_val(LINEAR);

	GLUI_Panel *magFilterPanel = glui->add_panel_to_panel(texFiltersPanel, "Magnifying filter", 1);
	GLUI_RadioGroup *magFilterGroup = glui->add_radiogroup_to_panel(magFilterPanel, (int*) &texMagFilter, -1, textureCB);
	glui->add_radiobutton_to_group(magFilterGroup, "Linear");
	glui->add_radiobutton_to_group(magFilterGroup, "Nearest");
	magFilterGroup->set_int_val(LINEAR);

	glui->add_column_to_panel(texFiltersPanel, 0);

	GLUI_Panel *texWrapSPanel = glui->add_panel_to_panel(texFiltersPanel, "Wrapping S", 1);
	GLUI_RadioGroup *texWrapSGroup = glui->add_radiogroup_to_panel(texWrapSPanel, (int*) &texWrap_S, -1, textureCB);
	glui->add_radiobutton_to_group(texWrapSGroup, "Repeat");
	glui->add_radiobutton_to_group(texWrapSGroup, "Clamp to edge");
	texWrapSGroup->set_int_val(CLAMPTOEDGE);

	GLUI_Panel *texWrapTPanel = glui->add_panel_to_panel(texFiltersPanel, "Wrapping T", 1);
	GLUI_RadioGroup *texWrapTGroup = glui->add_radiogroup_to_panel(texWrapTPanel, (int*) &texWrap_T, -1, textureCB);
	glui->add_radiobutton_to_group(texWrapTGroup, "Repeat");
	glui->add_radiobutton_to_group(texWrapTGroup, "Clamp to edge");
	texWrapTGroup->set_int_val(CLAMPTOEDGE);

	GLUI_Listbox *texEnvListbox = glui->add_listbox_to_panel(texturingPanel, "Environment", (int*)&texEnv, -1, textureCB);
	texEnvListbox->add_item(REPLACE, "GL_REPLACE");
	texEnvListbox->add_item(MODULATE, "GL_MODULATE");
	texEnvListbox->add_item(DECAL, "GL_DECAL");
	texEnvListbox->add_item(BLEND, "GL_BLEND");
	texEnvListbox->set_int_val(MODULATE);

	GLUI_Listbox *texGenListbox = glui->add_listbox_to_panel(texturingPanel, "UV Generation", (int*)&texGen, -1, textureCB);
	texGenListbox->add_item(OBJECT, "Object Linear");
	texGenListbox->add_item(EYE, "Eye Linear");
	texGenListbox->add_item(SPHERE, "Sphere Map");
	texGenListbox->set_int_val(OBJECT);

	GLUI_Panel *shadingPanel = glui->add_panel("Shading");
	GLUI_RadioGroup *shadingGroup = glui->add_radiogroup_to_panel(shadingPanel, (int*) &shadingModel, -1, shadingCB);
	glui->add_radiobutton_to_group(shadingGroup, "Flat");
	glui->add_radiobutton_to_group(shadingGroup, "Smooth");
	shadingGroup->set_int_val(SMOOTH);

	GLUI_Listbox *shaderListbox = glui->add_listbox_to_panel(shadingPanel, "Shader", (int*)&shader, -1, shadingCB);
	shaderListbox->add_item(NOSHADER, "Fixed function");
	shaderListbox->add_item(PASS_THROUGH, "Pass through");
	shaderListbox->add_item(DIFFUSE, "Lambert illumination");
	shaderListbox->add_item(PHONG, "Phong illumination");
	shaderListbox->add_item(TOON, "Toon shading");
	shaderListbox->add_item(PROCEDURAL, "Procedural texture");
	shaderListbox->set_int_val(PASS_THROUGH);

	glui->set_main_gfx_window(main_window);

	// We register the idle callback with GLUI, *not* with GLUT 
	GLUI_Master.set_glutIdleFunc(NULL);
	glui->sync_live();
	glutMainLoop();
	return EXIT_SUCCESS;
}
Exemplo n.º 3
0
 void UpdateDriverListboxGUI()
 {
   driver_listbox->set_int_val(cur_driver);
   //driver_listbox->set_int_val(cur_driver);
   UpdateDriverInfoGUI();
 }
Exemplo n.º 4
0
 void UpdateLinkListboxGUI()
 {
   link_listbox->set_int_val(cur_link);
   UpdateLinkInfoGUI();
   //driver_listbox->set_int_val(cur_driver);
 }