int main (int argc, char ** argv)
{
    if (argc<2)
    {
        printf ("usage: %s <trackfile>\n", argv[0]);
        exit(0);
    }
    
    loadSplines(argv[1]);
    
    glutInit(&argc, argv);
    
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize (500, 500);
    glutInitWindowPosition (100, 100);
    glutCreateWindow (argv[0]);
    init ();
    glClearDepth(1.0);
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    
    
    glutKeyboardFunc(handleKeypress);
    glutIdleFunc(doIdle);
    glutMotionFunc(mousedrag);
    glutPassiveMotionFunc(mouseidle);
    glutMouseFunc(mousebutton);
    
    glutMainLoop();
    return 0;
    
}
Exemplo n.º 2
0
int _tmain(int argc, _TCHAR* argv[])
{
	// I've set the argv[1] to track.txt.
	// To change it, on the "Solution Explorer",
	// right click "assign1", choose "Properties",
	// go to "Configuration Properties", click "Debugging",
	// then type your track file name for the "Command Arguments"
	if (argc<2)
	{  
		printf ("usage: %s <trackfile>\n", argv[0]);
		exit(0);
	}
	g_pFloorTexture = jpeg_read("Ground.jpg", NULL);
	if (!g_pFloorTexture)
	{
		printf("no ground texture file found. \n");
	}
	g_pFloorHeight = jpeg_read("Height.jpg", NULL);
	if (!g_pFloorHeight)
	{
		printf("no ground height file found. \n");
	}
	g_pSkyTexture = jpeg_read("Sky.jpg", NULL);
	if (!g_pFloorTexture)
	{
		printf("no sky texture file found. \n");
	}
	glutInit(&argc, (char**)argv);

	loadSplines(argv[1]);

	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);
	glutInitWindowSize(640, 480);
	glutInitWindowPosition(0, 0);
	glutCreateWindow("Assignment 2");

	/* tells glut to use a particular display function to redraw */
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);

	/* replace with any animate code */
	glutIdleFunc(doIdle);

	/* callback for mouse drags */
	glutMotionFunc(mousedrag);
	/* callback for idle mouse movement */
	glutPassiveMotionFunc(mouseidle);
	/* callback for mouse button changes */
	glutMouseFunc(mousebutton);


	/* do initialization */
	myinit();


	glutMainLoop();

	return 0;
}
Exemplo n.º 3
0
int main (int argc, char ** argv)
{
  	if (argc<2)
  	{  
  	printf ("usage: %s <trackfile>\n", argv[0]);
  	exit(0);
  	}


  	
  	loadSplines(argv[1]);
  	
	
  	
		/* create window */
  	glutInit(&argc,argv);
  	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);  
  	glutInitWindowSize(WIDTH, HEIGHT);
  	glutInitWindowPosition(0, 0);  
  	glutCreateWindow("Assignment 2 - Roller Coaster");   
  	
  	/* allow the user to quit using the right mouse button menu */
  	g_iMenuId = glutCreateMenu(menufunc); /* menu triggered function */
  	glutSetMenu(g_iMenuId);
  	glutAddMenuEntry("Quit",0);   		/* Menu item = (menu title, value) */
  	glutAttachMenu(GLUT_RIGHT_BUTTON);	/* which button trigger menu show up*/
  	
  	/* replace with any animate code */
  	glutIdleFunc(doIdle);
  	
  	/*  set GLUT callbacks */
  	glutDisplayFunc(display);        /* display function to redraw */	
  	glutMotionFunc(mousedrag);       /* callback for mouse drags */
  	glutPassiveMotionFunc(mouseidle);/* callback for idle mouse */
  	glutMouseFunc(mousebutton);      /* callback for mouse button */
  	glutReshapeFunc(reshape);	       /* reshape callback */
  	glutKeyboardFunc(keyboard);	     /* keyboard callback */  
  	  
  	/* do initialization */
  	myinit();
  	
  	/* cannot put before diaply*/
  	loadTexture();  	
  	
	/* start GLUT program - affect window showing */
  	glutMainLoop();    
  	  
  	  
  	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	// I've set the argv[1] to track.txt.
	// To change it, on the "Solution Explorer",
	// right click "assign2", choose "Properties",
	// go to "Configuration Properties", click "Debugging",
	// then type your track file name for the "Command Arguments"
	if (argc < 2)
	{
		printf("usage: %s <trackfile>\n", argv[0]);
		exit(0);
	}

	loadSplines(argv[1]);

	/* initialization */
	glutInit(&argc, (char**)argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	/* create window */
	glutInitWindowSize(640, 480);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("CSCI 420 Assignment 2 - Rollercoaster");

	/* used for double buffering */
	glEnable(GL_DEPTH_TEST);

	/* tells glut to use a particular display function to redraw */
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);

	/* replace with any animate code */
	glutIdleFunc(idle);

	/* user keyboard input */
	glutSpecialFunc(keySpecial);

	/* enable materials */

	myInit();

	glutMainLoop();

	return 0;
}
int main (int argc, char ** argv) { // main function
    if (argc<2) {
        printf ("usage: %s <trackfile>\n", argv[0]);
        exit(0);
    }

    loadSplines(argv[1]); // load up the splines

    // used to get the second spline, offset it to get two tracks
    for (int i=0; i<g_Splines[1].numControlPoints; i++) { // load up the second spline
        double x_offset = g_Splines[1].points[i].x;
        double y_offset = g_Splines[1].points[i].y;
        double z_offset = g_Splines[1].points[i].z;
        double normal = sqrt(pow(x_offset,2)+pow(y_offset,2)+pow(z_offset,2)); // normalize
        x_offset = x_offset/normal*-1.1; // to offset
        y_offset = y_offset/normal*-1.1;
        z_offset = z_offset/normal*-1.1;
        g_Splines[1].points[i].x = g_Splines[0].points[i].x + x_offset; // offset slightly from the original track
        g_Splines[1].points[i].y = g_Splines[0].points[i].y + y_offset;
        g_Splines[1].points[i].z = g_Splines[0].points[i].z + z_offset;
    }

    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE);
    glutInitWindowPosition(200,200); // window position on screen at 200,200
    glutInitWindowSize(640, 480); // window size is 640x480
    glutCreateWindow("CSCI480 Assignment 2 - Jeremy Chen"); // window title

    glutDisplayFunc(display);

    g_iMenuId = glutCreateMenu(menu); // create menu
    glutSetMenu(g_iMenuId);
    glutAddMenuEntry("Quit", 0);
    glutAddMenuEntry("Restart",1);
    glutAttachMenu(GLUT_RIGHT_BUTTON); // use right-button to get menu

    glutIdleFunc(doIdle);

    myinit();

    glutMainLoop();
}
Exemplo n.º 6
0
int _tmain(int argc, _TCHAR* argv[])
{
	// I've set the argv[1] to track.txt.
	// To change it, on the "Solution Explorer",
	// right click "assign1", choose "Properties",
	// go to "Configuration Properties", click "Debugging",
	// then type your track file name for the "Command Arguments"
	if (argc<2)
	{  
		printf ("usage: %s <trackfile>\n", argv[0]);
		exit(0);
	}
	loadSplines(argv[1]);

	/* Matrix mult test code
	GLdouble in1[16] = {1,4,1,1,2,3,4,3,3,1,2,2,4,2,3,4};
	GLdouble in2[16] = {3,8,7,9,2,3,4,3,3,1,2,2,4,2,3,4};
	GLdouble out[16];
	matrix4mult(in1,in2,out);
	out[0];
	*/
	//{{1,2,3,4},{4,3,1,2},{1,4,2,3},{1,3,2,4}} * {{1,2,3,4},{4,3,1,2},{1,4,2,3},{1,3,2,4}}

	glutInit(&argc,(char**)argv);

	/*create a window here double buffered and using depth testing */
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(640,480);
	glutInitWindowPosition(50,50);
	glutCreateWindow(argv[0]);

	/* tells glut to use a particular display function to redraw */
	glutDisplayFunc(display);

	/* allow the user to quit using the right mouse button menu */
	g_iMenuId = glutCreateMenu(menufunc);
	glutSetMenu(g_iMenuId);
	glutAddMenuEntry("Quit",0);
	glutAddMenuEntry("Capture Animation",4);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	/* replace with any animate code */
	glutIdleFunc(doIdle);

	/* callback for mouse drags */
	glutMotionFunc(mousedrag);
	/* callback for idle mouse movement */
	glutPassiveMotionFunc(mouseidle);
	/* callback for mouse button changes */
	glutMouseFunc(mousebutton);
	/* callback for reshaping window, also sets viewport and perspective */
	glutReshapeFunc(reshape);

	glutKeyboardFunc(keypress);

	/* do initialization */
	glInit();

	glutMainLoop();
	return 0;

}