Example #1
0
int main(int ac,char **av){
    int i;

    fprintf(stderr,"Bugs!\n");

	float xx,yy;

	glutInit(&ac, (char**) av);
    bugsinit(ac,av);

//    for(i=0;i<NROWS;i++)
//        nodes[i*ROWL+NROWS/2].food=i;
//    for(i=0;i<ROWL;i++)
//        nodes[ROWL*(NROWS/2)+i].food=i;
//	mtinit(ac,av);
	fprintf(stderr,"Transient...");
	for(i=0;i<transient;i++){
        updatebugs();
	}
	fprintf(stderr,"transient done.\n");

    prefsize(SIZEX,SIZEY);
	initgraph("Bugs!");
    yy = 1.2; xx = yy * XFAC;
    scale(-xx,xx,-yy,yy);

	
	glutMainLoop( );
return 0;
}
Example #2
0
int main(int argc, char *argv[])
{
  ginit();
  prefsize(640, 480);
  winopen("Asteroids");
  init();
  event_loop();
  gexit();
  return 0;
}
Example #3
0
    gfx::Size Label::GetPreferredSize()
    {
        // Return a size of (0, 0) if the label is not visible and if the
        // collapse_when_hidden_ flag is set.
        // TODO(munjal): This logic probably belongs to the View class. But for now,
        // put it here since putting it in View class means all inheriting classes
        // need ot respect the collapse_when_hidden_ flag.
        if(!IsVisible() && collapse_when_hidden_)
        {
            return gfx::Size();
        }

        gfx::Size prefsize(GetTextSize());
        gfx::Insets insets = GetInsets();
        prefsize.Enlarge(insets.width(), insets.height());
        return prefsize;
    }
Example #4
0
void main()
{
	short val;
	int menu, pres;
	float p, mx, my;

	curmass = 0.5;
	curdrag = 0.15;
	prefsize(800,640);
	initbuzz();
	winopen("dynadraw");
	glcompat(GLC_OLDPOLYGON,1);
	subpixel(1);
	shademodel(FLAT);
	gconfig();
	qdevice(LEFTMOUSE);
	qdevice(MIDDLEMOUSE);
	qdevice(MENUBUTTON);
	qdevice(RIGHTSHIFTKEY); 
	qdevice(UPARROWKEY); 
	qdevice(DOWNARROWKEY); 
	qdevice(RIGHTSHIFTKEY); 
	makeframe();
	menu = defpup("dynadraw %t|toggle line style|save PostScript");
	width = initwidth;
	mouse.fixedangle = 1;
	while(1) {
		switch(qread(&val)) {
		case REDRAW:
			makeframe();
			break;
		case MIDDLEMOUSE:
			if(val) 
				clearscreen();
			break;
		case UPARROWKEY:
			if(val) 
				initwidth *= 1.414213;
			width = initwidth;
			break;
		case DOWNARROWKEY:
			if(val) 
				initwidth /= 1.414213;
			width = initwidth;
			break;
		case MENUBUTTON:
			if(val) {
				switch(dopup(menu)) {
				case 1: 
					mouse.fixedangle = 1-mouse.fixedangle;
					break;
				case 2: 
					savepolys();
					break;
				}
			}
			break;
		case LEFTMOUSE:
			if(val) {
				my = getmousey();
				if(my>0*SLIDERHIGH && my<2*SLIDERHIGH) {
					if(my>SLIDERHIGH) {
						while(getbutton(LEFTMOUSE)) {
							p = paramval();
							if(p != curmass) {
								curmass = p;
								showsettings();
							}
						}
					} else {
						while(getbutton(LEFTMOUSE)) {
							p = paramval();
							if(p != curdrag) {
								curdrag = p;
								showsettings();
							}
						}
					}
				} else {
					mx = 1.25*fgetmousex();
					my = fgetmousey();
					filtersetpos(&mouse,mx,my);
					odelx = 0.0;
					odely = 0.0;
					while(getbutton(LEFTMOUSE)) {
						mx = 1.25*fgetmousex();
						my = fgetmousey();
						if(filterapply(&mouse,mx,my)) {
							drawsegment(&mouse);
							color(0);
							buzz();
						}
					}
				}
			}
			break;
		}
	}
}
Example #5
0
main()
{
        char    *p;
	float	tdir = TRANS;
	float	scal = 1.0 + SCAL;
	int	but, nplanes;
	int	x, y, i, n;
	short	val;
	int	bf = 1;
	int	fill = 1;

	prefsize(500L, 500L);

	vinit("mswin");
	winopen("lcube");

	unqdevice(INPUTCHANGE);
	qdevice(SKEY);
	qdevice(XKEY);
	qdevice(YKEY);
	qdevice(ZKEY);
	qdevice(EQUALKEY);
	qdevice(MINUSKEY);
	qdevice(ESCKEY);
	qdevice(QKEY);
	qdevice(FKEY);
	qdevice(BKEY);
	/* 
	 * Wait for REDRAW event ...
	 */
	while (qread(&val) != REDRAW)
		;
	

	window(-800.0, 800.0, -800.0, 800.0, -800.0, 800.0);
	lookat(0.0, 0.0, 1500.0, 0.0, 0.0, 0.0, 0);

	if ((nplanes = getplanes()) == 1)
		makecubes(0);

	makecubes(1);

	backface(1);
		
	doublebuffer();
	gconfig();

	/*
	 * Doublebuffer does a backbuffer(TRUE)....
	 */

	while(1) {
		x = 500 - (int)getvaluator(MOUSEX);
		y = 500 - (int)getvaluator(MOUSEY);
		x *= 3;
		y *= 3;
		pushmatrix();
			rotate(x, 'y');
			rotate(y, 'x');
			color(BLACK);
			clear();
			callobj((Object)3);
			if (nplanes == 1)
				callobj((Object)2);
		popmatrix();
		swapbuffers();

		if (qtest()) {
			but = qread(&val);
			but = qread(&val);	/* swallow up event */

			switch (but) {

			case SKEY:
				scale(scal, scal, scal);
				break;
			case XKEY:
				translate(tdir, 0.0, 0.0);
				break;
			case YKEY:
				translate(0.0, tdir, 0.0);
				break;
			case ZKEY:
				translate(0.0, 0.0, tdir);
				break;
			case MINUSKEY:
				tdir = -tdir;

				if (scal < 1.0)
					scal = 1.0 + SCAL;
				else
					scal = 1.0 - SCAL;

				break;
			case EQUALKEY:
				tdir = TRANS;
				break;
			case BKEY:
				bf = !bf;
				backface(bf);
				break;
			case FKEY:
				fill = !fill;
				if (fill)
					polymode(PYM_FILL);
				else
					polymode(PYM_LINE);
				break;
			case ESCKEY:
			case QKEY:
				gexit();
				exit(0);
			default:
				;
			}
		}
	}
}
Example #6
0
main()
{
    float ship[XY];
    long org[XY];
    long size[XY];
    Device dev;
    short val;
    Device mdev[XY];
    short mval[XY];
    long nhits;
    short buffer[BUFSIZE];
    Boolean run;

    prefsize(400, 400);
    winopen("select1");
    getorigin(&org[X], &org[Y]);
    getsize(&size[X], &size[Y]);
    mmode(MVIEWING);
    ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5);
    qdevice(LEFTMOUSE);
    qdevice(ESCKEY);
    color(BLACK);
    clear();
    mdev[X] = MOUSEX;
    mdev[Y] = MOUSEY;

    drawplanet();
    run = TRUE;
    while (run) {
	dev = qread(&val);
	if (val == 0) {				/* on upstroke */
	    switch (dev) {
	    case LEFTMOUSE:
		getdev(XY, mdev, mval);
		ship[X] = mval[X] - org[X];
		ship[Y] = mval[Y] - org[Y];
		color(BLUE);
		sbox(ship[X], ship[Y], 
		     ship[X] + SHIPWIDTH, ship[Y] + SHIPHEIGHT);

		/*
		 * specify the selecting region to be a box surrounding the
		 * rocket ship 
		 */
		ortho2(ship[X], ship[X] + SHIPWIDTH, 
		       ship[Y], ship[Y] + SHIPHEIGHT);

		initnames();
		gselect(buffer, BUFSIZE);
		    loadname(PLANET);
		    /* no actual drawing takes place */
		    drawplanet();
		nhits = endselect(buffer);

		/*
		 * restore the Projection matrix; NB. can't use push/popmatrix 
		 * since they only work for the ModelView matrix stack 
		 * when in MVIEWING mode
		 */
		ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5);

		/* 
		 * check to see if PLANET was selected; NB. nhits is NOT the
		 * number of buffer elements written
		 */
		if (nhits < 0) {
		    fprintf(stderr, "gselect buffer overflow\n");
		    run = FALSE;
		} 
		else if (nhits >= 1 && buffer[0] == 1 && buffer[1] == PLANET)
		    ringbell();
		break;
	    case ESCKEY:
		run = FALSE;
		break;
	    }
	}
    }
    gexit();
    return 0;
}