コード例 #1
0
ファイル: main.cpp プロジェクト: anirul/3DStereo
int main(int ac, char** av) {

	spheres[0].x = 0.5f;
	spheres[0].y = 0.5f;
	spheres[0].z = 0.5f;

	spheres[1].x = 0.5f;
	spheres[1].y = 0.5f;
	spheres[1].z = 0.5f;

	spheres[2].x = 0.5f;
	spheres[2].y = 0.5f;
	spheres[2].z = 0.5f;

	nbSpeheres = 3;

	glutInit(&ac, av);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	
	glutInitWindowSize(640, 480);
	glutCreateWindow("GL blobs viewer");
	glutFullScreen();
	
	init();
	CameraHome();
	update();
	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutReshapeFunc(HandleReshape);
	glutMainLoop();
	return 0;
}
コード例 #2
0
ファイル: triangle.c プロジェクト: magestik/glQuadBufferEmu
int main(int argc,char **argv)
{
	int i;


   /* The camera attributes are passed from server to client as necessary */
   CameraHome();
	camera.stereo       = NOSTEREO;
   camera.cursordepth  = camera.focallength;
   camera.screenwidth  = 400;
   camera.screenheight = 300;

	options.fullscreen   = FALSE;


	/* Parse the command line arguments */
   for (i=1;i<argc;i++) {
      if (strcmp(argv[i],"-h") == 0)
         fprintf(stderr,"%s -f (for fullscreen) -s (for active stereo) -ss (for passive stereo)\n",argv[0]);
      if (strcmp(argv[i],"-f") == 0)
         options.fullscreen = !options.fullscreen;
      if (strcmp(argv[i],"-s") == 0)
         camera.stereo = ACTIVESTEREO;
		if (strcmp(argv[i],"-ss") == 0) {
         camera.stereo = DUALSTEREO;
			camera.screenwidth *= 2;
		}
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   if (camera.stereo == ACTIVESTEREO)
		glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO);
	else
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	/* Create the window and handlers */
   glutCreateWindow("triangle");
	glutReshapeWindow(camera.screenwidth,camera.screenheight);
   if (options.fullscreen)
      glutFullScreen();
   glutDisplayFunc(HandleDisplay);
	glutReshapeFunc(HandleReshape);

	/*
		The client doesn't deal with user input
		Turn of the mouse since it is a killer in passive stereo
		to have a mouse on only one screen.
	*/
   glutKeyboardFunc(HandleKeyboard);
   glutMotionFunc(HandleMouseMotion);
	glutSetCursor(GLUT_CURSOR_NONE);
   CreateEnvironment();

	/* Ready to go! */
   glutMainLoop();
   return(0);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: anirul/3DStereo
void keyboard(unsigned char key, int x, int y) {
	switch (key) {
		case 27 :
			// supposed to quit
			exit(0);
			break;
		case 'h':                           /* Go home     */
		case 'H':
			CameraHome();
			break;
	}
}
コード例 #4
0
ファイル: planet.c プロジェクト: CaptainOz/WorldGen
/*
   Deal with plain key strokes
*/
void HandleKeyboard(unsigned char key,int x, int y)
{
   switch (key) {
   case ESC:                            /* Quit */
   case 'Q':
   case 'q': 
      exit(0); 
      break;
   case 'h':                           /* Go home     */
   case 'H':
      CameraHome(0);
      break;
   case '[':                           /* Roll anti clockwise */
      RotateCamera(0,0,-1);
      break;
   case ']':                           /* Roll clockwise */
      RotateCamera(0,0,1);
      break;
   case 'i':                           /* Translate camera up */
   case 'I':
      TranslateCamera(0,1);
      break;
   case 'k':                           /* Translate camera down */
   case 'K':
      TranslateCamera(0,-1);
      break;
   case 'j':                           /* Translate camera left */
   case 'J':
      TranslateCamera(-1,0);
      break;
   case 'l':                           /* Translate camera right */
   case 'L':
      TranslateCamera(1,0);
      break;
   case '=':
   case '+':
      FlyCamera(1);
      break;
   case '-':
   case '_':
      FlyCamera(-1);
      break;
   case 'w':                           /* Write the image to disk */
   case 'W':
      windowdump = !windowdump;
      break;
   case 'r':
   case 'R':
      record = !record;
      break;
   case '<':
   case ',':
      iterationdepth--;
      if (iterationdepth < 0)
         iterationdepth = 0;
      geometrydirty = REALDIRTY;
      break;
   case '>':
   case '.':
      iterationdepth++;
      geometrydirty = REALDIRTY;
      break;
   }
}
コード例 #5
0
ファイル: planet.c プロジェクト: CaptainOz/WorldGen
int main(int argc,char **argv)
{
   int i;
   int mainmenu,itermenu,heightmenu,resolmenu;
   int methodmenu,colourmenu;

   camera.screenwidth = 800;
   camera.screenheight = 600;

   /* Parse the command line arguments */
   for (i=1;i<argc;i++) {
      if (strstr(argv[i],"-h") != NULL) 
         GiveUsage(argv[0]);
      if (strstr(argv[i],"-f") != NULL)
         fullscreen = TRUE;
      if (strstr(argv[i],"-s") != NULL)
         stereo = TRUE;
      if (strstr(argv[i],"-d") != NULL)
         debug = TRUE;
      if (strstr(argv[i],"-D") != NULL)
         demomode = TRUE;
      if (strstr(argv[i],"-S") != NULL)
          sscanf( argv[++i], "%i", &seedvalue );
      if (strstr(argv[i],"-F") != NULL)
          sscanf( argv[++i], "%i", &spheredepth );
      if (strstr(argv[i],"--origin") != NULL)
          whichmethod = 1;
      if (strstr(argv[i],"--notorigin") != NULL)
          whichmethod = 2;
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   if (!stereo)
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   else
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO);

   glutCreateWindow("Planet creation example");
   glutReshapeWindow(camera.screenwidth,camera.screenheight);
   if (fullscreen)
      glutFullScreen();
   glutDisplayFunc(Display);
   glutReshapeFunc(HandleReshape);
   glutVisibilityFunc(HandleVisibility);
   glutKeyboardFunc(HandleKeyboard);
   glutSpecialFunc(HandleSpecialKeyboard);
   glutMouseFunc(HandleMouse);
   glutMotionFunc(HandleMouseMotion);

   nface = FormSphere(spheredepth);
   CreateEnvironment();
   CameraHome(0);

   /* Iteration menu */
   itermenu = glutCreateMenu(HandleIterMenu);
   glutAddMenuEntry("Decrease iteration depth",1);
   glutAddMenuEntry("Increase iteration depth",2);
   glutAddMenuEntry("Do 100 more",3);
   glutAddMenuEntry("Do 1000 more",4);
   glutAddMenuEntry("Reset",5);

   /* Height menu */
   heightmenu = glutCreateMenu(HandleHeightMenu);
   glutAddMenuEntry("Low",1);
   glutAddMenuEntry("Average",2);
   glutAddMenuEntry("High",3);

   /* Sphere resolution menu */
   resolmenu = glutCreateMenu(HandleResolMenu);
   glutAddMenuEntry("Low (8192 facets)",5);
   glutAddMenuEntry("Average (32768 facets)",6);
   glutAddMenuEntry("High (131072 facets)",7);
   glutAddMenuEntry("Extreme (524288 facets)",8);

   /* Colour map menu */
   colourmenu = glutCreateMenu(HandleColourMenu);
   glutAddMenuEntry("Mars 1",11);
   glutAddMenuEntry("Mars 2",12);
   glutAddMenuEntry("Earth (Sea to snow)",15);
   glutAddMenuEntry("Extreme earth",10);
   glutAddMenuEntry("Land to snow",13);
   glutAddMenuEntry("Grey Scale",3);
   glutAddMenuEntry("Hot to cold",1);

   /* Algorithm menu */
   methodmenu = glutCreateMenu(HandleMethodMenu);
   glutAddMenuEntry("Plane through origin",1);
   glutAddMenuEntry("Plane not through origin",2);

   /* Set up the main menu */
   mainmenu = glutCreateMenu(HandleMainMenu);
   glutAddSubMenu("Iteration depth",itermenu);
   glutAddSubMenu("Height control",heightmenu);
   glutAddSubMenu("Sphere resolution",resolmenu);
   glutAddSubMenu("Colour map",colourmenu);
   glutAddSubMenu("Algorithm",methodmenu);
   glutAddMenuEntry("Toggle lights on/off",1);
   glutAddMenuEntry("Toggle wireframe/solid",2);
   glutAddMenuEntry("Toggle construction on/off",3);
   glutAddMenuEntry("Toggle smooth shading on/off",4);
   glutAddMenuEntry("Toggle ocean on/off",5);
   glutAddMenuEntry("Change seed",9);
   glutAddMenuEntry("Quit",10);
   glutAttachMenu(GLUT_RIGHT_BUTTON);

   /* Ready to go! */
   glutMainLoop();
   return(0);
}