Beispiel #1
0
//------------------------------------------------------------------------------
int main(int argc, char ** argv) {

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGBA |GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(1024, 1024);
    glutCreateWindow("OpenSubdiv test");

    std::string str;
    if (argc > 1) {
        std::ifstream ifs(argv[1]);
        if (ifs) {
            std::stringstream ss;
            ss << ifs.rdbuf();
            ifs.close();
            str = ss.str();

            g_defaultShapes.push_back(SimpleShape(str.c_str(), argv[1], kCatmark));
        }
    }



    initializeShapes();

    int smenu = glutCreateMenu(modelMenu);
    for(int i = 0; i < (int)g_defaultShapes.size(); ++i){
        glutAddMenuEntry( g_defaultShapes[i].name.c_str(), i);
    }

    int lmenu = glutCreateMenu(levelMenu);
    for(int i = 1; i < 8; ++i){
        char level[16];
        sprintf(level, "Level %d\n", i);
        glutAddMenuEntry(level, i);
    }

    // Register Osd compute kernels
    OpenSubdiv::OsdCpuKernelDispatcher::Register();
    OpenSubdiv::OsdGlslKernelDispatcher::Register();

#if OPENSUBDIV_HAS_OPENCL
    OpenSubdiv::OsdClKernelDispatcher::Register();
#endif

#if OPENSUBDIV_HAS_CUDA
    OpenSubdiv::OsdCudaKernelDispatcher::Register();

    // Note: This function randomly crashes with linux 5.0-dev driver.
    // cudaGetDeviceProperties overrun stack..?
    cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() );
#endif

    int kmenu = glutCreateMenu(kernelMenu);
    int nKernels = OpenSubdiv::OsdKernelDispatcher::kMAX;

    for(int i = 0; i < nKernels; ++i)
        if(OpenSubdiv::OsdKernelDispatcher::HasKernelType(
               OpenSubdiv::OsdKernelDispatcher::KernelType(i)))
            glutAddMenuEntry(getKernelName(i), i);

    glutCreateMenu(menu);
    glutAddSubMenu("Level", lmenu);
    glutAddSubMenu("Model", smenu);
    glutAddSubMenu("Kernel", kmenu);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMouseFunc(mouse);
    glutKeyboardFunc(keyboard);
    glutMotionFunc(motion);
    glewInit();
    initGL();

    const char *filename = NULL;

    for (int i = 1; i < argc; ++i) {
        if (!strcmp(argv[i], "-d"))
            g_level = atoi(argv[++i]);
        else if (!strcmp(argv[i], "-c"))
            g_repeatCount = atoi(argv[++i]);
        else
            filename = argv[i];
    }

    glGenBuffers(1, &g_indexBuffer);

    modelMenu(0);

    glutIdleFunc(idle);
    glutMainLoop();

    quit();
}
Beispiel #2
0
int main(int argc, char *argv[])
{
	// inicjalizacja biblioteki GLUT
	glutInit(&argc, argv);

	// inicjalizacja bufora ramki
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	// rozmiary głównego okna programu
	glutInitWindowSize(550, 550);

	// utworzenie głównego okna programu
	glutCreateWindow("Kompresja tekstur");

	// dołączenie funkcji generującej scenę 3D
	glutDisplayFunc(DisplayScene);

	// dołączenie funkcji wywoływanej przy zmianie rozmiaru okna
	glutReshapeFunc(Reshape);

	// utworzenie podmenu - Tekstura
	int MenuTexture = glutCreateMenu(Menu);
	glutAddMenuEntry("lena.tga (kompresja)", TEXTURE_LENA);
	glutAddMenuEntry("lena.tga (bez kompresji)", TEXTURE_LENA_UNC);
	glutAddMenuEntry("lena_gray.tga (kompresja)", TEXTURE_LENA_GRAY);
	glutAddMenuEntry("lena_gray.tga (bez kompresji)", TEXTURE_LENA_GRAY_UNC);

	// utworzenie podmenu - GL_TEXTURE_COMPRESSION_HINT
	int MenuTextureCompressionHint = glutCreateMenu(Menu);
	glutAddMenuEntry("GL_FASTEST", TEXTURE_COMPRESSION_FASTEST);
	glutAddMenuEntry("GL_DONT_CARE", TEXTURE_COMPRESSION_DONT_CARE);
	glutAddMenuEntry("GL_NICEST", TEXTURE_COMPRESSION_NICEST);

	// utworzenie podmenu - Aspekt obrazu
	int MenuAspect = glutCreateMenu(Menu);
#ifdef WIN32

	glutAddMenuEntry("Aspekt obrazu - całe okno", FULL_WINDOW);
#else

	glutAddMenuEntry("Aspekt obrazu - cale okno", FULL_WINDOW);
#endif

	glutAddMenuEntry("Aspekt obrazu 1:1", ASPECT_1_1);

	// menu główne
	glutCreateMenu(Menu);
	glutAddSubMenu("Tekstura", MenuTexture);
	glutAddSubMenu("GL_TEXTURE_COMPRESSION_HINT", MenuTextureCompressionHint);
	glutAddSubMenu("Aspekt obrazu", MenuAspect);

#ifdef WIN32

	glutAddMenuEntry("Wyjście", EXIT);
#else

	glutAddMenuEntry("Wyjscie", EXIT);
#endif

	// określenie przycisku myszki obsługującego menu podręczne
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// utworzenie tekstur
	GenerateTextures();

	// sprawdzenie i przygotowanie obsługi wybranych rozszerzeń
	ExtensionSetup();

	// wprowadzenie programu do obsługi pętli komunikatów
	glutMainLoop();
	return 0;
}
Beispiel #3
0
/*
 *----------------------------------------------------------
 *      initMenu
 *      Initializes all menu options
 *----------------------------------------------------------
 */
void initMenus( void )
{
    mainMenuIdent = glutCreateMenu( mainMenu );
    primitiveMenuIdent = glutCreateMenu( primitiveMenu );
    printMenuIdent = glutCreateMenu( printMenu );
    dispMenuIdent = glutCreateMenu( dispMenu );
    viewMenuIdent = glutCreateMenu( viewMenu );
    renderMenuIdent = glutCreateMenu( renderMenu );
    vectorMenuIdent = glutCreateMenu( vectorFieldMenu );
    savingMenuIdent = glutCreateMenu( savingMenu );
    typeDistanciaMenuIdent = glutCreateMenu( typeDistance );
    hsvColorsMenuIdent = glutCreateMenu( hsvColorsMenu );

    /* Create primitive submenu */
    glutSetMenu( primitiveMenuIdent );
    glutAddMenuEntry("Cylinder", CYLINDER);
    glutAddMenuEntry("LandMark", LANDMARK);
    glutAddMenuEntry("Sphere", SPHERE);

    /* Render submenu */
    glutSetMenu( renderMenuIdent );
    glutAddMenuEntry( "Fill", FILL);
    glutAddMenuEntry( "Wire", WIRE);
    glutAddMenuEntry( "Halo", HALO);
    glutAddMenuEntry( "Edges", EDGES);

    /* Create type distance submenu*/
    glutSetMenu( typeDistanciaMenuIdent );
    glutAddMenuEntry("Straight Path", 0);
    glutAddMenuEntry("Straight Path using angle", 1);
	if (useGeodeiscDistances)
	{
		glutAddMenuEntry("Geodesic Path", 2);
		glutAddMenuEntry("Geodesic Path using angle", 3);
	}

	/*Created by Fabiane Qeiroz at 23/09/2010
	 *Create type Vector Field*/
	glutSetMenu( typeVectorFieldMenuIdent );
	glutAddMenuEntry("Faces Vector Field (Default)", 0);
	glutAddMenuEntry("Vertices Vector Field", 1);

    /* Display submenu */
    glutSetMenu( dispMenuIdent );
    glutAddMenuEntry( "Primitives", 0);
    glutAddMenuEntry( "LandMarks", 1);
    glutAddMenuEntry( "Axes", 2);
    glutAddMenuEntry( "Object", 3);
    glutAddMenuEntry( "Color", 4);
    glutAddMenuEntry( "Grid", 5);
    glutAddMenuEntry( "Vectors", 6);
    glutAddMenuEntry( "BW output", 7);  /* Thompson 05/07/2002 */
    glutAddMenuEntry( "Voronoi Borders", 8);
    glutAddMenuEntry( "Cells", 9);
	glutAddMenuEntry( "Degree Vector", 10); /* Thompson 07/11/2003 */
	glutAddMenuEntry( "Normal Vector", 11); /* Vinicius 17/09/2004 */
	glutAddSubMenu( "HSV Colors", hsvColorsMenuIdent); /* Ricardo 29/05/2012 */

	/* HSV Colors submenu */
	glutSetMenu( hsvColorsMenuIdent ); /* Ricardo 29/05/2012 */
	glutAddMenuEntry( "Base vector X", 0);
	glutAddMenuEntry( "Base vector Y", 1);
	glutAddMenuEntry( "Base vector Z", 2);
	glutAddMenuEntry( "Disable", 3);

    /* Print information submenu */
    glutSetMenu( printMenuIdent );
    glutAddMenuEntry("Vertices", 0);
    glutAddMenuEntry("Faces", 1);
    glutAddMenuEntry("Primitives", 2);
    glutAddMenuEntry("Active Prim", 3);
    glutAddMenuEntry("Edges", 4);
    glutAddMenuEntry("Cells", 5);

    /* type of view: top, side, front or perspective submenu */
    glutSetMenu( viewMenuIdent );
    glutAddMenuEntry("Top", TOP);
    glutAddMenuEntry("Side", SIDE);
    glutAddMenuEntry("Front", FRONT);
    glutAddMenuEntry("Perspective", PERSPECTIVE);

        /* Vector field submenu */
    glutSetMenu( vectorMenuIdent );
	glutAddMenuEntry("Create Vector", 0);
    //glutAddMenuEntry("Initial Point", 0);
    //glutAddMenuEntry("Final Point", 1);
    glutAddMenuEntry("Draw Control Vectors", 1);
	glutAddMenuEntry("Print List of Vectors", 2);
	glutAddMenuEntry("Draw Faces Vector Field", 3);
	glutAddMenuEntry("Draw Vertices Vector Field", 4);
	glutAddMenuEntry("Remove Vector", 5);

	glutAddSubMenu("Type Distance", typeDistanciaMenuIdent );

	/* Saving submenu */
	glutSetMenu( savingMenuIdent );
	glutAddMenuEntry("Write Optik", 0);
    glutAddMenuEntry("Write Vertigo", 1);
    glutAddMenuEntry("Save Exp File", 2);
    glutAddMenuEntry("Save Session File", 3);
    glutAddMenuEntry("Save Prim File", 4);
    glutAddMenuEntry("Save Inventor File", 5);
    glutAddMenuEntry("Save Obj File", 6);
	glutAddMenuEntry("Save Pattern File", 7);
	glutAddMenuEntry("Save Control Vectors Field", 8);
	glutAddMenuEntry("Save Vectors Field", 9);

	glutSetMenu( mainMenuIdent );
	/* sub menus */
    glutAddSubMenu("Create Primitive", primitiveMenuIdent);
    glutAddSubMenu("Print Info", printMenuIdent);
    glutAddSubMenu("Rendering", renderMenuIdent);
    glutAddSubMenu("View", viewMenuIdent);
    glutAddSubMenu("Display", dispMenuIdent);
	glutAddSubMenu("Vector Field", vectorMenuIdent);
	glutAddSubMenu("Saving", savingMenuIdent);

    /* individual options */
    glutAddMenuEntry("Zoom out", 0);
    glutAddMenuEntry("Light", 1);
    glutAddMenuEntry("4 Windows", 2);
    glutAddMenuEntry("Parametrize", 3);
    glutAddMenuEntry("Texture", 4);
    glutAddMenuEntry("Compute Voronoi", 5);
    glutAddMenuEntry("Cell Picking", 6);
    glutAddMenuEntry("Poly Picking", 7);
    glutAddMenuEntry("Random Cells", 8);
    glutAddMenuEntry("Duplicate Prim", 9);
    glutAddMenuEntry("Grow", 10);
    glutAddMenuEntry("Animate", 11);
    glutAddMenuEntry("Exit", 12);
    glutAddMenuEntry("Optimize Voronoi", 13);

    /* specify which mouse button activates the menu */
    glutAttachMenu( GLUT_RIGHT_BUTTON );
}
Beispiel #4
0
int main(int argc, char **argv)
{
	int c_smenu, rotatefan, mouserotate, sofatranslate, scalecompound, viewtype, housewall, lightsonoff;
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(500, 500);
	glutCreateWindow("3D HOUSE");
	initfirst();
	glutDisplayFunc(first);
	glutKeyboardFunc(keyboard2);
	
	housewall = glutCreateMenu(housewallfunc);
	glutAddMenuEntry("Use LineLoop ", 1);
	glutAddMenuEntry("Use Polygon ", 2);

	lightsonoff = glutCreateMenu(lightsfunc);
	glutAddMenuEntry("On ", 1);
	glutAddMenuEntry("Off ", 2);

	viewtype = glutCreateMenu(viewtypefunc);
	glutAddMenuEntry("Orthographic View ", 1);
	glutAddMenuEntry("Perspective View ", 2);

	sofatranslate = glutCreateMenu(translatesofa);
	glutAddMenuEntry("On (Use keys w,a,s,d) ", 1);
	glutAddMenuEntry("Off ", 2);

	scalecompound = glutCreateMenu(scalecompoundheight);
	glutAddMenuEntry("x1 ", 1);
	glutAddMenuEntry("x1.5", 2);
	glutAddMenuEntry("x2.0", 3);
	glutAddMenuEntry("x2.5", 4);

	mouserotate = glutCreateMenu(rotateHouse);
	glutAddMenuEntry("Mouse On ", 1);
	glutAddMenuEntry("Mouse Off ", 2);

	rotatefan = glutCreateMenu(rotateMenu);
	glutAddMenuEntry("On ", 1);
	glutAddMenuEntry("Off ", 2);
	glutAddMenuEntry("Increase speed ", 3);
	glutAddMenuEntry("Decrease speed ", 4);

	c_smenu = glutCreateMenu(backMenu);
	glutAddMenuEntry("Red ", 1);
	glutAddMenuEntry("Blue ", 2);
	glutAddMenuEntry("Grean ", 3);
	glutAddMenuEntry("Black ", 4);

	glutCreateMenu(main_menu);
	glutAddMenuEntry("Exit", 1);
	glutAddSubMenu("Rotation of fan", rotatefan);
	glutAddSubMenu("Change Color", c_smenu);
	glutAddSubMenu("House Rotation", mouserotate);
	glutAddSubMenu("Translate Sofa", sofatranslate);
	glutAddSubMenu("Scale the height of compound wall", scalecompound);
	glutAddSubMenu("Lighting", lightsonoff);
	glutAddSubMenu("View", viewtype);
	glutAddSubMenu("House Walls", housewall);
	glutAddMenuEntry("Default Mode", 9);
	glutAttachMenu(GLUT_RIGHT_BUTTON);
	glutMainLoop();
	return 0;
}
Beispiel #5
0
int main(int argc, char* argv[]) {
	//process commandline arguments
	int argFile=0, argTransformation=0;
	char *argFileName;
	int i, j, tmp;
	j=argc-1; //tracking, if all the arguments were processed
	for (i=1; i<argc; i++) {
		//skipping argv[0] - program name
		if (strcmp(argv[i], "--help")==0 || strcmp(argv[i], "-h")==0) {
			fprintf(stderr, "usage: %s [options]\n", argv[0]);
			//fprintf(stderr, "");
			fprintf(stderr, "\t-h\n\t--help\n");
			fprintf(stderr, "\t\tthis help message\n");
			fprintf(stderr, "\t-d\n\t--debug\n");
			fprintf(stderr, "\t\tprint debug messages\n");
			fprintf(stderr, "\t-f <file_name>\n\t--file <file_name>\n");
			fprintf(stderr, "\t\tload this map file\n");
			fprintf(stderr, "\t-t <0|1|2>\n\t--transformation <0|1|2>\n");
			fprintf(stderr, "\t\tdefine, how coordinate transformation should happen\n");
			exit(1);
		} else if (strcmp(argv[i], "--debug")==0 || strcmp(argv[i], "-d")==0) {
			argDebug=1;
			j--;
		} else if (strcmp(argv[i], "--file")==0 || strcmp(argv[i], "-f")==0) {
			argFile=1;
			j--;

			if (i<argc) {
				i++; //preventing loop from reading this argument again
				argFileName=argv[i];
			}
			j--;
		} else if (strcmp(argv[i], "--transformation")==0 || strcmp(argv[i], "-t")==0) {
			//
			j--;

			if (i<argc) {
				i++; //preventing loop from reading this argument again
				argTransformation=atoi(argv[i]);
			}
			j--;
		}
	}
	if (j!=0) {
		//if all the arguments were processed sucessfully, j should be 0
		fprintf(stderr, "error: wrong parameters, exiting");
		exit(1);
	}
	
	// load map file
	if (argFile==1) {
		tmp=readPolishFile(argFileName); //read the map file to datastructure objects
	} else {
		tmp=readPolishFile("sample_map.mp"); //read the map file to datastructure objects
	}
	if (tmp==1) {
		//there was an error with reading the map file
		fprintf(stderr, "error: couldn't load map file, exiting");
		exit(1);
	}
	computeCoordinates(); //compute world coordinates from lon/lat data
//	printAll();

	//Init
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	//glutInitWindowSize(300, 300);
	glutCreateWindow("Map GL");

	//create the display lists
	displayNet();
//printf("************debug: pm");
	displayPolishMap();
	
	// << Init

	// >> Callback fuggvenyek

	//glutReshapeFunc(ChangeSizeOrtho); // Parhuzamos vetites
	glutReshapeFunc(ChangeSizePerspective); // Perspektiv vetites

	glutDisplayFunc(Display);
	glutSpecialFunc(SpecialKeys);
	glutKeyboardFunc(Keyboard);
	glutTimerFunc(1000, Timer, 1); // 1 mp mulva meghivodik a Timer() fuggveny
	//glutIdleFunc(Idle); // Idle(), ha nem tortenik semmi
	
	// << Callback fuggvenyek

	// >> Menu

	IdleMenu = glutCreateMenu(ProcessMenu);
	glutAddMenuEntry("Idle kiiratas bekapcsolasa", 3);
	glutAddMenuEntry("Idle kiiratas kikapcsolasa", 4);

	MenuID = glutCreateMenu(ProcessMenu);
	glutAddMenuEntry("1. menupont", 1);
	glutAddMenuEntry("2. menupont", 2);
	glutAddSubMenu("Idle fuggveny", IdleMenu);
	glutAddMenuEntry("Kilepes", 5);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// << Menu

	SetupRC();
	glutMainLoop();
	
	return 0;
}
Beispiel #6
0
void create_menu()
{
	int objects_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" Box         ", 1);
	glutAddMenuEntry(" Cylinder    ", 2);
    glutAddMenuEntry(" Sphere      ", 3);
    glutAddMenuEntry(" Pyramid     ", 4);
    glutAddMenuEntry(" Model       ", 5);


    // TODO Assignment 3: uncomment this
    /*int lights_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Toggle Draw ", 6);
	glutAddMenuEntry(" Directional ", 7);
	glutAddMenuEntry(" Point       ", 8);
	glutAddMenuEntry(" Spot        ", 9);*/

	int camera_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" Fovy        ", 10);
	glutAddMenuEntry(" Aspect      ", 11);
	glutAddMenuEntry(" Width       ", 12);
	glutAddMenuEntry(" Height      ", 13);
	glutAddMenuEntry(" Near        ", 14);
	glutAddMenuEntry(" Far         ", 15);
	glutAddMenuEntry(" Toggle Draw ", 16);
	glutAddMenuEntry(" Clear Focus ", 17);
	glutAddMenuEntry(" Ortho       ", 18);
	glutAddMenuEntry(" Frustum     ", 19);
	glutAddMenuEntry(" Perspective ", 20);

	int mode_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" Point       ", 21);
	glutAddMenuEntry(" Line        ", 22);
	glutAddMenuEntry(" Fill        ", 23);


	// TODO Assignment 3: uncomment this
	/*int ambient_id = glutCreateMenu(color_menu);
	glutAddMenuEntry(" Red         ", 0);
	glutAddMenuEntry(" Orange      ", 1);
	glutAddMenuEntry(" Yellow      ", 2);
	glutAddMenuEntry(" Green       ", 3);
	glutAddMenuEntry(" Blue        ", 4);
	glutAddMenuEntry(" Indigo      ", 5);
	glutAddMenuEntry(" Violet      ", 6);
	glutAddMenuEntry(" Black       ", 7);
	glutAddMenuEntry(" White       ", 8);
	glutAddMenuEntry(" Brown       ", 9);

	int diffuse_id = glutCreateMenu(color_menu);
	glutAddMenuEntry(" Red         ", 10);
	glutAddMenuEntry(" Orange      ", 11);
	glutAddMenuEntry(" Yellow      ", 12);
	glutAddMenuEntry(" Green       ", 13);
	glutAddMenuEntry(" Blue        ", 14);
	glutAddMenuEntry(" Indigo      ", 15);
	glutAddMenuEntry(" Violet      ", 16);
	glutAddMenuEntry(" Black       ", 17);
	glutAddMenuEntry(" White       ", 18);
	glutAddMenuEntry(" Brown       ", 19);

	int specular_id = glutCreateMenu(color_menu);
	glutAddMenuEntry(" Red         ", 20);
	glutAddMenuEntry(" Orange      ", 21);
	glutAddMenuEntry(" Yellow      ", 22);
	glutAddMenuEntry(" Green       ", 23);
	glutAddMenuEntry(" Blue        ", 24);
	glutAddMenuEntry(" Indigo      ", 25);
	glutAddMenuEntry(" Violet      ", 26);
	glutAddMenuEntry(" Black       ", 27);
	glutAddMenuEntry(" White       ", 28);
	glutAddMenuEntry(" Brown       ", 29);

	int attenuation_id = glutCreateMenu(attenuation_menu);
	glutAddMenuEntry(" Range 7     ",  0);
	glutAddMenuEntry(" Range 13    ",  1);
	glutAddMenuEntry(" Range 20    ",  2);
	glutAddMenuEntry(" Range 32    ",  3);
	glutAddMenuEntry(" Range 50    ",  4);
	glutAddMenuEntry(" Range 65    ",  5);
	glutAddMenuEntry(" Range 100   ",  6);
	glutAddMenuEntry(" Range 160   ",  7);
	glutAddMenuEntry(" Range 200   ",  8);
	glutAddMenuEntry(" Range 325   ",  9);
	glutAddMenuEntry(" Range 600   ",  10);
	glutAddMenuEntry(" Range 3250  ",  11);


	int shading_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" Flat        ", 25);
	glutAddMenuEntry(" Smooth      ", 26);*/

	int culling_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" None        ", 28);
	glutAddMenuEntry(" Back        ", 29);
	glutAddMenuEntry(" Front       ", 30);

	int normal_id = glutCreateMenu(canvas_menu);
	glutAddMenuEntry(" None        ", 31);
	glutAddMenuEntry(" Face        ", 32);
	glutAddMenuEntry(" Vertex      ", 33);

    canvas_menu_id = glutCreateMenu(canvas_menu);
    glutAddSubMenu  (" Objects     ", objects_id);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Lights      ", lights_id);
    glutAddSubMenu  (" Cameras     ", camera_id);
    glutAddSubMenu  (" Polygon     ", mode_id);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Shading     ", shading_id);
    glutAddSubMenu  (" Culling     ", culling_id);
    glutAddSubMenu  (" Normals     ", normal_id);
    glutAddMenuEntry(" Quit        ", 0);

    // TODO Assignment 3: uncomment this
    /*int material_menu_id = glutCreateMenu(object_menu);
	glutAddMenuEntry(" White       ", 10);
	glutAddMenuEntry(" Gouraud     ", 9);
	glutAddMenuEntry(" Phong       ", 8);
	glutAddMenuEntry(" Custom      ", 7);*/
    // TODO Assignment 4: uncomment this
	//glutAddMenuEntry(" Texture     ", 6);

    object_menu_id = glutCreateMenu(object_menu);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Material    ", material_menu_id);
    glutAddMenuEntry(" Set Focus   ", 5);
    glutAddMenuEntry(" Translate   ", 1);
    glutAddMenuEntry(" Rotate      ", 2);
    glutAddMenuEntry(" Scale       ", 3);
    glutAddMenuEntry(" Delete      ", 0);

    // TODO Assignment 3: uncomment this
    /*light_menu_id = glutCreateMenu(object_menu);
    glutAddSubMenu  (" Ambient     ", ambient_id);
	glutAddSubMenu  (" Diffuse     ", diffuse_id);
	glutAddSubMenu  (" Specular    ", specular_id);
	glutAddSubMenu  (" Attenuation ", attenuation_id);
	glutAddMenuEntry(" Set Focus   ", 5);
	glutAddMenuEntry(" Translate   ", 1);
	glutAddMenuEntry(" Rotate      ", 2);
	glutAddMenuEntry(" Delete      ", 0);*/

	camera_menu_id = glutCreateMenu(object_menu);
	glutAddMenuEntry(" Set Active  ", 4);
	glutAddMenuEntry(" Set Focus   ", 5);
	glutAddMenuEntry(" Translate   ", 1);
	glutAddMenuEntry(" Rotate      ", 2);
	glutAddMenuEntry(" Scale       ", 3);
	glutAddMenuEntry(" Delete      ", 0);

    glutSetMenu(canvas_menu_id);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    glutMenuStatusFunc(menustatusfunc);
}
Beispiel #7
0
static void PopulateOCIOMenus()
{
    OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
    
    int csMenuID = glutCreateMenu(imageColorSpace_CB);

    std::map<std::string, int> families;
    for(int i=0; i<config->getNumColorSpaces(); ++i)
    {
        const char * csName = config->getColorSpaceNameByIndex(i);
        if(csName && *csName)
        {
            OCIO::ConstColorSpaceRcPtr cs = config->getColorSpace(csName);
            if(cs)
            {
                const char * family = cs->getFamily();
                if(family && *family)
                {
                    if(families.find(family)==families.end())
                    {
                        families[family] = glutCreateMenu(imageColorSpace_CB);
                        glutAddMenuEntry(csName, i);

                        glutSetMenu(csMenuID);
                        glutAddSubMenu(family, families[family]);
                    }
                    else
                    {
                        glutSetMenu(families[family]);
                        glutAddMenuEntry(csName, i);
                    }
                }
                else
                {
                    glutSetMenu(csMenuID);
                    glutAddMenuEntry(csName, i);
                }
            }
        }
    }
    
    int deviceMenuID = glutCreateMenu(displayDevice_CB);
    for(int i=0; i<config->getNumDisplays(); ++i)
    {
        glutAddMenuEntry(config->getDisplay(i), i);
    }
    
    int transformMenuID = glutCreateMenu(transform_CB);
    const char * defaultDisplay = config->getDefaultDisplay();
    for(int i=0; i<config->getNumViews(defaultDisplay); ++i)
    {
        glutAddMenuEntry(config->getView(defaultDisplay, i), i);
    }
    
    int lookMenuID = glutCreateMenu(look_CB);
    for(int i=0; i<config->getNumLooks(); ++i)
    {
        glutAddMenuEntry(config->getLookNameByIndex(i), i);
    }
    
    glutCreateMenu(menuCallback);
    glutAddSubMenu("Image ColorSpace", csMenuID);
    glutAddSubMenu("Transform", transformMenuID);
    glutAddSubMenu("Device", deviceMenuID);
    glutAddSubMenu("Looks Override", lookMenuID);
    
    glutAttachMenu(GLUT_RIGHT_BUTTON);
}
Beispiel #8
0
int
main(int argc, char** argv)
{
    int buffering = GLUT_DOUBLE;
    struct dirent* direntp;
    DIR* dirp;
    int models;

    glutInitWindowSize(512, 512);
    glutInit(&argc, argv);

    while (--argc) {
	if (strcmp(argv[argc], "-sb") == 0)
	    buffering = GLUT_SINGLE;
	else
	    model_file = argv[argc];
    }

    if (!model_file) {
	model_file = "data/dolphins.obj";
    }

    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | buffering);
    glutCreateWindow("Smooth");
  
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    models = glutCreateMenu(menu);
    dirp = opendir(DATA_DIR);
    if (!dirp) {
	fprintf(stderr, "%s: can't open data directory.\n", argv[0]);
    } else {
	while ((direntp = readdir(dirp)) != NULL) {
	    if (strstr(direntp->d_name, ".obj")) {
		entries++;
		glutAddMenuEntry(direntp->d_name, -entries);
	    }
	}
	closedir(dirp);
    }

    glutCreateMenu(menu);
    glutAddMenuEntry("Smooth", 0);
    glutAddMenuEntry("", 0);
    glutAddSubMenu("Models", models);
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("[w]   Toggle wireframe/filled", 'w');
    glutAddMenuEntry("[c]   Toggle culling on/off", 'c');
    glutAddMenuEntry("[n]   Toggle face/smooth normals", 'n');
    glutAddMenuEntry("[b]   Toggle bounding box on/off", 'b');
    glutAddMenuEntry("[p]   Toggle frame rate on/off", 'p');
    glutAddMenuEntry("[t]   Toggle model statistics", 't');
    glutAddMenuEntry("[m]   Toggle color/material/none mode", 'm');
    glutAddMenuEntry("[r]   Reverse polygon winding", 'r');
    glutAddMenuEntry("[s]   Scale model smaller", 's');
    glutAddMenuEntry("[S]   Scale model larger", 'S');
    glutAddMenuEntry("[o]   Weld redundant vertices", 'o');
    glutAddMenuEntry("[+]   Increase smoothing angle", '+');
    glutAddMenuEntry("[-]   Decrease smoothing angle", '-');
    glutAddMenuEntry("[W]   Write model to file (out.obj)", 'W');
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("[Esc] Quit", 27);
    glutAttachMenu(GLUT_RIGHT_BUTTON);
  
    init();
  
    glutMainLoop();
    return 0;
}
Beispiel #9
0
int
main(int argc, char **argv)
{
  int win1, win2, men1, men2, men3;

  glutInit(&argc, argv);

  if (0 != glutGetMenu()) {
    printf("FAIL: current menu wrong, should be zero\n");
    exit(1);
  }
  if (0 != glutGetWindow()) {
    printf("FAIL: current window wrong, should be zero\n");
    exit(1);
  }
  glutInitWindowSize(140, 140);

  /* Make sure initial glut init display mode is right. */
  if (glutGet(GLUT_INIT_DISPLAY_MODE) != (GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH)) {
    printf("FAIL: init display mode wrong\n");
    exit(1);
  }
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_STENCIL);
  if (glutGet(GLUT_INIT_DISPLAY_MODE) != (GLUT_RGBA | GLUT_SINGLE | GLUT_STENCIL)) {
    printf("FAIL: display mode wrong\n");
    exit(1);
  }
  /* Interesting case:  creating menu before creating windows. */
  men1 = glutCreateMenu(menuSelect);

  /* Make sure glutCreateMenu doesn't change init display mode. 
   */
  if (glutGet(GLUT_INIT_DISPLAY_MODE) != (GLUT_RGBA | GLUT_SINGLE | GLUT_STENCIL)) {
    printf("FAIL: display mode changed\n");
    exit(1);
  }
  if (men1 != glutGetMenu()) {
    printf("FAIL: current menu wrong\n");
    exit(1);
  }
  glutAddMenuEntry("hello", 1);
  glutAddMenuEntry("bye", 2);
  glutAddMenuEntry("yes", 3);
  glutAddMenuEntry("no", 4);
  glutAddSubMenu("submenu", 5);

  win1 = glutCreateWindow("test24");
  glutDisplayFunc(display);

  if (win1 != glutGetWindow()) {
    printf("FAIL: current window wrong\n");
    exit(1);
  }
  if (men1 != glutGetMenu()) {
    printf("FAIL: current menu wrong\n");
    exit(1);
  }
  men2 = glutCreateMenu(menuSelect);
  glutAddMenuEntry("yes", 3);
  glutAddMenuEntry("no", 4);
  glutAddSubMenu("submenu", 5);

  /* Make sure glutCreateMenu doesn't change init display mode. 
   */
  if (glutGet(GLUT_INIT_DISPLAY_MODE) != (GLUT_RGBA | GLUT_SINGLE | GLUT_STENCIL)) {
    printf("FAIL: display mode changed\n");
    exit(1);
  }
  if (men2 != glutGetMenu()) {
    printf("FAIL: current menu wrong\n");
    exit(1);
  }
  if (win1 != glutGetWindow()) {
    printf("FAIL: current window wrong\n");
    exit(1);
  }
  win2 = glutCreateWindow("test24 second");
  glutDisplayFunc(display);

  if (win2 != glutGetWindow()) {
    printf("FAIL: current window wrong\n");
    exit(1);
  }
  glutDestroyWindow(win2);

  if (0 != glutGetWindow()) {
    printf("FAIL: current window wrong, should be zero\n");
    exit(1);
  }
  men3 = glutCreateMenu(menuSelect);
  glutAddMenuEntry("no", 4);
  glutAddSubMenu("submenu", 5);

  if (glutGet(GLUT_INIT_DISPLAY_MODE) != (GLUT_RGBA | GLUT_SINGLE | GLUT_STENCIL)) {
    printf("FAIL: display mode changed\n");
    exit(1);
  }
  glutDestroyMenu(men3);

  if (0 != glutGetMenu()) {
    printf("FAIL: current menu wrong, should be zero\n");
    exit(1);
  }
  glutTimerFunc(2 * 1000, timer, 23);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Beispiel #10
0
int main(int argc, char *argv[])
{
	// inicjalizacja biblioteki GLUT
	glutInit(&argc, argv);

	// inicjalizacja bufora ramki
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	// rozmiary głównego okna programu
	glutInitWindowSize(500, 500);

	// utworzenie głównego okna programu
	glutCreateWindow("Zadanie 3");

	// dołączenie funkcji generującej scenę 3D
	glutDisplayFunc(DisplayScene);

	// dołączenie funkcji wywoływanej przy zmianie rozmiaru okna
	glutReshapeFunc(Reshape);

	// dołączenie funkcji obsługi klawiatury
	glutKeyboardFunc(Keyboard);

	// obsługa przycisków myszki
	glutMouseFunc(MouseButton);

	// obsługa ruchu kursora myszki
	glutMotionFunc(MouseMotion);

	// utworzenie podmenu - Planeta
	int MenuPlanet = glutCreateMenu(Menu);
	glutAddMenuEntry("Wenus", VENUS_TEX);
	glutAddMenuEntry("Ziemia", EARTH_TEX);
	glutAddMenuEntry("Mars", MARS_TEX);
	glutAddMenuEntry("Jowisz", JUPITER_TEX);

	// utworzenie podmenu - Filtr pomniejszający
	int MenuMinFilter = glutCreateMenu(Menu);
	glutAddMenuEntry("GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST);
	glutAddMenuEntry("GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR);
	glutAddMenuEntry("GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST);
	glutAddMenuEntry("GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR);

	// utworzenie podmenu - Aspekt obrazu
	int MenuAspect = glutCreateMenu(Menu);
#ifdef WIN32

	glutAddMenuEntry("Aspekt obrazu - całe okno", FULL_WINDOW);
#else

	glutAddMenuEntry("Aspekt obrazu - cale okno", FULL_WINDOW);
#endif

	glutAddMenuEntry("Aspekt obrazu 1:1", ASPECT_1_1);

	// menu główne
	glutCreateMenu(Menu);
	glutAddSubMenu("Planeta", MenuPlanet);

#ifdef WIN32

	glutAddSubMenu("Filtr pomniejszający", MenuMinFilter);
	glutAddSubMenu("Aspekt obrazu", MenuAspect);
	glutAddMenuEntry("Wyjście", EXIT);
#else

	glutAddSubMenu("Filtr pomniejszajacy", MenuMinFilter);
	glutAddSubMenu("Aspekt obrazu", MenuAspect);
	glutAddMenuEntry("Wyjscie", EXIT);
#endif

	// określenie przycisku myszki obsługującego menu podręczne
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// utworzenie tekstur
	GenerateTextures();

	// sprawdzenie i przygotowanie obsługi wybranych rozszerzeñ
	ExtensionSetup();

	// wprowadzenie programu do obsługi pętli komunikatów
	glutMainLoop();
	return 0;
}
Beispiel #11
0
void
glutMenu(void)
{

  int glut_menu[13];

  glut_menu[5] = glutCreateMenu(null_select);
  glutAddMenuEntry("forward       : q,w", 0);
  glutAddMenuEntry("backwards     : a,s", 0);
  glutAddMenuEntry("outwards      : z,x", 0);
  glutAddMenuEntry("inwards       : Z,X", 0);

  glut_menu[6] = glutCreateMenu(null_select);
  glutAddMenuEntry("upwards       : Q,W", 0);
  glutAddMenuEntry("downwards     : A,S", 0);
  glutAddMenuEntry("outwards      : 1,2", 0);
  glutAddMenuEntry("inwards       : 3,4", 0);

  glut_menu[1] = glutCreateMenu(null_select);
  glutAddMenuEntry(" : Page_up", 0);

  glut_menu[8] = glutCreateMenu(null_select);
  glutAddMenuEntry("forward       : y,u", 0);
  glutAddMenuEntry("backwards     : h.j", 0);
  glutAddMenuEntry("outwards      : Y,U", 0);
  glutAddMenuEntry("inwards       : H,J", 0);

  glut_menu[9] = glutCreateMenu(null_select);
  glutAddMenuEntry("forward       : n,m", 0);
  glutAddMenuEntry("backwards     : N,M", 0);

  glut_menu[9] = glutCreateMenu(null_select);
  glutAddMenuEntry("forward       : n,m", 0);
  glutAddMenuEntry("backwards     : N,M", 0);

  glut_menu[10] = glutCreateMenu(null_select);
  glutAddMenuEntry("toes up       : K,L", 0);
  glutAddMenuEntry("toes down     : k,l", 0);

  glut_menu[11] = glutCreateMenu(null_select);
  glutAddMenuEntry("right         : right arrow", 0);
  glutAddMenuEntry("left          : left arrow", 0);
  glutAddMenuEntry("down          : up arrow", 0);
  glutAddMenuEntry("up            : down arrow", 0);

  glut_menu[12] = glutCreateMenu(null_select);
  glutAddMenuEntry("right         : p", 0);
  glutAddMenuEntry("left          : i", 0);
  glutAddMenuEntry("up            : 9", 0);
  glutAddMenuEntry("down          : o", 0);

  glut_menu[4] = glutCreateMenu(NULL);
  glutAddSubMenu("at the shoulders? ", glut_menu[5]);
  glutAddSubMenu("at the elbows?", glut_menu[6]);

  glut_menu[7] = glutCreateMenu(NULL);
  glutAddSubMenu("at the hip? ", glut_menu[8]);
  glutAddSubMenu("at the knees?", glut_menu[9]);
  glutAddSubMenu("at the ankles? ", glut_menu[10]);

  glut_menu[2] = glutCreateMenu(null_select);
  glutAddMenuEntry("turn left    : d", 0);
  glutAddMenuEntry("turn right    : g", 0);

  glut_menu[3] = glutCreateMenu(null_select);
  glutAddMenuEntry("tilt backwards : f", 0);
  glutAddMenuEntry("tilt forwards  : r", 0);

  glut_menu[0] = glutCreateMenu(NULL);
  glutAddSubMenu("move the arms.. ", glut_menu[4]);
  glutAddSubMenu("fire the vulcan guns?", glut_menu[1]);
  glutAddSubMenu("move the legs.. ", glut_menu[7]);
  glutAddSubMenu("move the torso?", glut_menu[2]);
  glutAddSubMenu("move the hip?", glut_menu[3]);
  glutAddSubMenu("rotate the scene..", glut_menu[11]);
#ifdef MOVE_LIGHT
  glutAddSubMenu("rotate the light source..", glut_menu[12]);
#endif

  glutCreateMenu(menu_select);
#ifdef ANIMATION
  glutAddMenuEntry("Start Walk", 1);
  glutAddMenuEntry("Stop Walk", 2);
#endif
  glutAddMenuEntry("Toggle Wireframe", 3);
  glutAddSubMenu("How do I ..", glut_menu[0]);
  glutAddMenuEntry("Quit", 4);
  glutAttachMenu(GLUT_LEFT_BUTTON);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
}