Exemple #1
0
void  InitSGI  ()
{
   ginit ();		/* Initialize the display. */
   ginit_done = true;

   cursoff ();

   RGBmode ();		/* Select RGB mode (24-bit color). */
   gconfig ();
   RGBcolor (0, 0, 0);
   clear ();

   qdevice (KEYBD);
}
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;
		}
	}
}
Exemple #3
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:
				;
			}
		}
	}
}
Exemple #4
0
main()
{
	int	i, itest,  dobackface, dofill, dodouble;
	char	buf[100];
	float	H;
	short	idata;
	int	xr, yr;

	vinit("mswin");
	winopen("piston");
	/* 
	 * Wait for REDRAW event ...
	 */
	while (qread(&idata) != REDRAW)
		;

	doublebuffer();

	gconfig();

	unqdevice(INPUTCHANGE);
	qdevice(QKEY);
	qdevice(FKEY);
	qdevice(BKEY);
	qdevice(ESCKEY);
        qdevice(REDRAW);

	makecyl();

	polymode(PYM_FILL);

	backface(1);
/*
 * set up a perspective projection with a field of view of
 * 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1,
 * and the far clipping plane at 1000.0.
 */
	perspective(400, 1.5, 0.1, 600.0);
	lookat(0.0, -6.0, 4., 0.0, 0.0, 0.0, 0);

/*
 * here we loop back here adnaseum until someone hits a key
 */
	xr = yr = 0;

 	while(1) {
		for (i = 0; i < 360; i += 5) {
			color(BLACK);
			clear();
			color(RED);
			H = 1.0 + cos(2.0 * 3.14159265*i / 180.0);

			yr = 500 - (int)getvaluator(MOUSEY);
			xr = 500 - (int)getvaluator(MOUSEX);
			yr = 500 - (int)getvaluator(MOUSEY);
			xr *= 3;
			yr *= 3;

			pushmatrix();
				rotate(xr, 'x');
				rotate(yr, 'y');
				piston(H);
			popmatrix();

			if (dodouble)
				swapbuffers();

			if (qtest()) {
				itest = qread(&idata);
				itest = qread(&idata); /* Zap Up event */
				if (itest == BKEY) {
					dobackface = !dobackface;
					backface(dobackface);
				} else if (itest == FKEY) {
					dofill = !dofill;
					if (dofill)
						polymode(PYM_FILL);
					else
						polymode(PYM_LINE);
				} else if(itest == QKEY || itest == ESCKEY) {
					 gexit();
					 exit(0);
				}

			}
		}
	}
}
Exemple #5
0
/* init_matplot: initialises distmat plotting. The matrix size should
 * be Row x Col (which is the min. size in pixels). Title is put on the top
 * of the window by the window manager. Xorig and Yorig specify
 * the lower left corner position of the window: if either of them
 * is negative, then the window will be positioned interactively.
 * Return value: the 'gid' window ID number.
 */
long init_matplot(unsigned int Row, unsigned int Col, char *Title, 
	long Xorig, long Yorig)
{
    const unsigned int MINSIZE=500;
    
    long Gid, Xsize, Ysize, Xmax, Ymax;
    float Xmagnif, Ymagnif;
    unsigned int Rs, Cs;
    
    if (!Row) Row=MINSIZE;
    if (!Col) Col=MINSIZE;
    
    Xmagnif=(float)Col/MINSIZE;
    Ymagnif=(float)Row/MINSIZE;
    Rs=Row; Cs=Col;
    if (Col<=Row)
    {
	if (Xmagnif<1.0)
	{
	    Cs=MINSIZE;
	    Rs=round_id(Row/Xmagnif);
	}
    }
    else
    {
	if (Ymagnif<1.0)
	{
	    Rs=MINSIZE;
	    Cs=round_id(Col/Ymagnif);
	}
    }
    
    foreground();	/* enable signal catch etc. */
    Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX);
    keepaspect(Col, Row);

    /* Xmax,Ymax: the maximal screen coordinates */
    Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX);
    if (Xorig+Cs>Xmax) Xorig=Xmax-Cs;
    if (Yorig+Rs>Ymax) Yorig=Ymax-Rs;
    if (Xorig>=0 && Yorig>=0)
	prefposition(Xorig, Xorig+Cs, Yorig, Yorig+Rs);
    iconsize(84, 67);
    Gid=winopen(Title);	/* create window */
    
    RGBmode();
    /* check if double buffering is available */
    if (Dblbuffer=getgdesc(GD_BITS_NORM_DBL_BLUE))
    { doublebuffer(); gconfig(); }
    else fputs("init_matplot: single-buffer mode\n", stderr);

    /* enable resize */
    winconstraints();
    keepaspect(Col, Row);
    winconstraints();
    
    getsize(&Xsize, &Ysize);    /* scale drawing into window */
    Xmagnif=(float)Xsize/Col;
    Ymagnif=(float)Ysize/Row;
    pushmatrix();
    scale(Xmagnif, Ymagnif, 1.0);
    cpack(RGB_BLACK); clear();          /* clears window to black */
    if (Dblbuffer) { swapbuffers(); cpack(RGB_BLACK); clear(); }
    
    /* queue input events */
    qdevice(ESCKEY); qdevice(WINFREEZE); qdevice(WINTHAW);
    qdevice(REDRAWICONIC); qdevice(WINQUIT);
    
    return(Gid);
}