Esempio n. 1
0
vrpn_SGIBox::vrpn_SGIBox(char * name, vrpn_Connection * c):
  vrpn_Analog(name, c), vrpn_Button_Filter(name, c) {
    int ret;
    char hn[128];
    sid  = -1;
    winid =  -1;

    if (winid != -1) {
      printf("Closing previous windows Winid=%d, sid = %d:\n",winid, sid);
      winclose(winid);
      //dglclose(sid);
      dglclose(-1); // close all dgl connection;
    }

    ret = gethostname(hn, 100);
    if (ret < 0) {
      fprintf(stderr, "vrpn_SGIBox: error in gethostname()\n");
      return;
    }
    sid = ret = dglopen(hn,DGLLOCAL);
    if (ret < 0) {
      fprintf(stderr, "vrpn_SGIBox: error in dglopen()\n");
      return;
    }
    noport();
    winid = winopen("");
    reset();
    num_channel = NUM_DIALS;
    num_buttons = NUM_BUTTONS;
    
    register_autodeleted_handler(c->register_message_type( vrpn_got_first_connection), sgibox_con_cb, this);
    register_autodeleted_handler(alert_message_id,sgibox_alert_handler, this);
    set_alerts(1);	//turn on alerts from toggle filter class to notify
			//local sgibox that lights should be turned on/off
}
Esempio n. 2
0
int
main(int argc, char* argv[])
{
	int c;
	extern int optind;
	extern char* optarg;

	while ((c = getopt(argc, argv, "c:p:r:")) != -1)
		switch (c) {
		case 'b':		/* save as b&w */
			photometric = PHOTOMETRIC_MINISBLACK;
			break;
		case 'c':		/* compression scheme */
			if (streq(optarg, "none"))
				compression = COMPRESSION_NONE;
			else if (streq(optarg, "packbits"))
				compression = COMPRESSION_PACKBITS;
			else if (strneq(optarg, "jpeg", 4)) {
				char* cp = strchr(optarg, ':');
				if (cp && isdigit(cp[1]))
					quality = atoi(cp+1);
				if (cp && strchr(cp, 'r'))
					jpegcolormode = JPEGCOLORMODE_RAW;
				compression = COMPRESSION_JPEG;
			} else if (strneq(optarg, "lzw", 3)) {
				char* cp = strchr(optarg, ':');
				if (cp)
					predictor = atoi(cp+1);
				compression = COMPRESSION_LZW;
			} else
				usage();
			break;
		case 'p':		/* planar configuration */
			if (streq(optarg, "separate"))
				config = PLANARCONFIG_SEPARATE;
			else if (streq(optarg, "contig"))
				config = PLANARCONFIG_CONTIG;
			else
				usage();
			break;
		case 'r':		/* rows/strip */
			rowsperstrip = atoi(optarg);
			break;
		case '?':
			usage();
			/*NOTREACHED*/
		}
	if (argc - optind != 1 && argc - optind != 5)
		usage();
	xmaxscreen = getgdesc(GD_XPMAX)-1;
	ymaxscreen = getgdesc(GD_YPMAX)-1;
	foreground();
	noport();
	winopen("tiffsv");
	if (argc - optind == 5)
		tiffsv(argv[optind],
		    atoi(argv[optind+1]), atoi(argv[optind+2]),
		    atoi(argv[optind+3]), atoi(argv[optind+4]));
	else
		tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen);
	return (0);
}
Esempio n. 3
0
int main ()
{
    object ellipsoid;
    int depth;
    int run;

    long min_syscall = -1;
    long min_init = -1;
    long min_seq = -1;
    long min_par = -1;
    long min_libsphere_draw = -1;
    long min_libsphere = -1;

    /*
    // Find the fastest execution time among 100 runs
    // of gettimeofday system call.
    */
    for (run = 1; run <= max_run; run++) {
        //gettimeofday (&t0);
        //gettimeofday (&t1);

 //       microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
        if (min_syscall > microsec || min_syscall < 0)
            min_syscall = microsec;
    }

    /*
    // Find the fastest execution time among 100 runs
    // of ellipsoid initialization for each depth.
    */
    for (depth = 1; depth <= max_depth; depth++) {
        for (run = 1; run <= max_run; run++) {
            //gettimeofday (&t0);
            ellipsoid_init (depth);
            //gettimeofday (&t1);
            ellipsoid_done ();

  //          microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
            if (min_init > microsec || min_init < 0)
                min_init = microsec;
        }
        min_init -= min_syscall;
        timing[depth-1].init = min_init;
        min_init = -1;
    }

    /*
    // Find the fastest execution time among 100 runs
    // of ellipsoid generation by ellipsoid_seq() for each depth.
    */
    ellipsoid_init (max_depth);
    for (depth = 1; depth <= max_depth; depth++) {
        for (run = 1; run <= max_run; run++) {
            //gettimeofday (&t0);
            ellipsoid_seq (&ellipsoid, depth, 1.0, 2.0, 3.0);
            //gettimeofday (&t1);
            ellipsoid_free (&ellipsoid);

//            microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
            if (min_seq > microsec || min_seq < 0)
                min_seq = microsec;
        }
        min_seq -= min_syscall;
        timing[depth-1].seq = min_seq;
        min_seq = -1;
    }

    /*
    // Find the fastest execution time among 100 runs
    // of ellipsoid generation by ellipsoid_par() for each depth.
    */
    ellipsoid_init (max_depth);
    for (depth = 1; depth <= max_depth; depth++) {
        for (run = 1; run <= max_run; run++) {
            //getrimeofday (&t0);
            ellipsoid_par (&ellipsoid, depth, 1.0, 2.0, 3.0);
            //getrimeofday (&t1);
            ellipsoid_free (&ellipsoid);

            //microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
            if (min_par > microsec || min_par < 0)
                min_par = microsec;
        }
        min_par -= min_syscall;
        timing[depth-1].par = min_par;
        min_par = -1;
    }

    /*
    // Find the fastest execution time among 100 runs
    // of sphere generation by IRIS GL sphere library for each depth.
    */
    foreground ();
    noport ();
    winopen ("");
    sphmode (SPH_TESS, SPH_OCT); /* octahedral subdivision */
    sphmode (SPH_PRIM, SPH_POLY);
    for (depth = 1; depth <= SPH_MAXDEPTH; depth++) {
        static float sphparams[] = { 0.0, 0.0, 0.0, 1.0 };

        /*
        // Find the fastest execution time among 100 runs
        // of sphere drawing by IRIS GL sphere library.
        */
        sphmode (SPH_DEPTH, depth);
        sphdraw (sphparams); /* generation and drawing of the sphere */
        for (run = 1; run <= max_run; run++) {
            finish (); /* block until the geometry pipeline is empty */
            //getrimeofday (&t0);
            sphdraw (sphparams); /* drawing only without generation */
            //getrimeofday (&t1);

            //microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
            if (min_libsphere_draw > microsec || min_libsphere_draw < 0)
                min_libsphere_draw = microsec;
        }
        sphfree ();
        min_libsphere_draw -= min_syscall;

        /*
        // Find the fastest execution time among 100 runs
        // of sphere generation by IRIS GL sphere library.
        */
        for (run = 1; run <= max_run; run++) {
            sphmode (SPH_DEPTH, depth);
            finish ();
            //getrimeofday (&t0);
            sphdraw (sphparams); /* generation and drawing of the sphere */
            //getrimeofday (&t1);
            sphfree ();

            //microsec = (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec);
            if (min_libsphere > microsec || min_libsphere < 0)
                min_libsphere = microsec;
        }
        min_libsphere -= min_libsphere_draw + min_syscall;
        timing[depth-1].libsphere = min_libsphere;
        min_libsphere = -1;
    }

    for (depth = 1; depth <= max_depth; depth++) {
        printf ("depth = %3d: nv = %8d, nf = %8d, init = %8ld, seq = %8ld, par = %8ld",
            depth, 4*depth*depth + 2, 8*depth*depth,
            timing[depth-1].init, timing[depth-1].seq, timing[depth-1].par);
        if (depth <= SPH_MAXDEPTH)
            printf (", libsphere = %8ld", timing[depth-1].libsphere);
        printf ("\n");
    }

    return 0;
}