void display(void) { renderPicture(); drawit(); std::cout<<"Drew picture"<<std::endl; }
void display (void) { int i; int j; clearFramebuffer (); for (i = 0;i < ImageH; i++) { for (j = 0; j < ImageW; j++) { rayCast (i, j); } } drawit (); }
int main() { /* MIRACL rational calculator */ int i,j,k,p,q,c,hpos; BOOL over,help; screen(); #if MIRACL==16 mip=mirsys(10,0); /*** 16-bit computer ***/ #else mip=mirsys(6,0); /*** 32-bit computer ***/ #endif mip->ERCON=TRUE; x=mirvar(0); for (i=0;i<=top;i++) y[i]=mirvar(0); m=mirvar(0); t=mirvar(0); radeg=mirvar(0); loge2=mirvar(0); loge10=mirvar(0); eps=mirvar(0); mip->pi=mirvar(0); cinstr(mip->pi,cpi); /* read in constants */ fpmul(mip->pi,1,180,radeg); cinstr(loge2,clg2); cinstr(loge10,clg10); cinstr(eps,ceps); help=OFF; show(TRUE); p=6; q=0; flag=OFF; newx=OFF; over=FALSE; setopts(); clrall(); drawit(); while (!over) { /* main loop */ if (mip->ERNUM) { aprint(ORDINARY,4+5*p,6+3*q,keys[q][p]); p=5,q=0; } if (width==80 || !help) { aprint(INVER,4+5*p,6+3*q,keys[q][p]); curser(1,24); c=gethit(); aprint(ORDINARY,4+5*p,6+3*q,keys[q][p]); } else while ((c=gethit())!='H') ; result=TRUE; if ((k=arrow(c))!=0) { /* arrow key hit */ if (k==1 && q>0) q--; if (k==2 && q<5) q++; if (k==3 && p<6) p++; if (k==4 && p>0) p--; continue; } if (c=='H') { /* switch help on/off */ help=!help; for (i=1;i<=24;i++) { if (width==80) hpos=41; else hpos=1; if (help) aprint(HELPCOL,hpos,i,htext[i-1]); else lclr(hpos,i); } if (width==40 && !help) drawit(); continue; } if (c>='A' && c<='F') { /* hex only */ if (!next(c)) putchar(BELL); else show(FALSE); continue; } for (j=0;j<6;j++) for (i=0;i<7;i++) if (c==qkeys[j][i]) p=i,q=j,c=' '; if (c==8 || c==127) p=6,q=1,c=' '; /* aliases */ if (c==',' || c=='a') p=5,q=5,c=' '; if (c=='O' || c==ESC) p=6,q=0,c=' '; if (c==13) p=6,q=5,c=' '; if (c=='[' || c=='{') p=3,q=5,c=' '; if (c==']' || c=='}') p=4,q=5,c=' '; if (c=='d') p=5,q=2,c=' '; if (c=='b') p=5,q=3,c=' '; if (c=='^') p=3,q=2,c=' '; if (c==' ') over=act(p,q); else continue; absol(x,t); if (fcomp(t,eps)<0) zero(x); if (result) { /* output result to display */ cotstr(x,mip->IOBUFF); just((char *)mip->IOBUFF); if (mip->ERNUM<0) { /* convert to radix and try again */ mip->ERNUM=0; mip->RPOINT=ON; cotstr(x,mip->IOBUFF); putchar(BELL); just((char *)mip->IOBUFF); } clr(); } if (newx) { /* update display */ getstat(); show(FALSE); } } curser(1,24); restore(); return 0; }
int main (int argc, char **argv) { char q, action; double mat[4][4], minv[4][4], scaleFactor; double radians = 3 * (M_PI / 180); FILE *g; int cc, sign, currentObj, k, h; int increment = 15; int xcounter, ycounter, zcounter = 0; for (cc = 1; cc < argc; cc++) { g = fopen(argv[cc], "r"); //opens a file; r = read only if (g == NULL) { //if the file is empty, it will let me know printf("can't open (1)\n"); exit(1); } else { readobject(g, cc); D3d_make_identity(mat); D3d_make_identity(minv); scaleFactor = scale_n_fit(cc); D3d_translate(mat, minv, -centerx, -centery, -centerz); D3d_scale(mat, minv, scaleFactor, scaleFactor, scaleFactor); D3d_mat_mult_points(x[cc], y[cc], z[cc], mat, x[cc], y[cc], z[cc], points[cc]); // printarray(z[cc], points[cc]); } } welcome(argc - 1); scanf("%c", &q); currentObj = q - '0'; sign = 1 ; action = 't' ; if (currentObj < argc && currentObj > 0) { G_init_graphics(WIDTH, HEIGHT); while (1) { G_rgb(0, 0, 0); G_clear(); drawit(currentObj); D3d_make_identity (mat) ; D3d_make_identity (minv) ; q = G_wait_key() ; if (q == 'q') { exit(0) ; } else if (q == 'c') { sign = -sign ; } else if (q == 't') { action = q ; } else if (q == 's') { reverse = -reverse; } else if (q == 'r') { action = q ; } else if (('0' <= q) && (q <= '9')) { k = q - '0' ; if (h != currentObj) { currentObj = k; } } else if ((q == 'x') && (action == 't')) { D3d_translate (mat, minv, sign * increment, 0, 0); xcounter = xcounter + (sign * increment); } else if ((q == 'y') && (action == 't')) { D3d_translate (mat, minv, 0, sign * increment, 0); ycounter = ycounter + (sign * increment); } else if ((q == 'z') && (action == 't')) { D3d_translate(mat, minv, 0, 0, sign * increment); zcounter = zcounter + (sign * increment); } else if ((q == 'x') && (action == 'r')) { D3d_translate(mat, minv, -xcounter, -ycounter, -zcounter); D3d_rotate_x(mat, minv, sign * radians); D3d_translate(mat, minv, xcounter, ycounter, zcounter); } else if ((q == 'y') && (action == 'r')) { D3d_translate(mat, minv, -xcounter, -ycounter, -zcounter); D3d_rotate_y(mat, minv, sign * radians); D3d_translate(mat, minv, xcounter, ycounter, zcounter); } else if ((q == 'z') && (action == 'r')) { D3d_translate(mat, minv, -xcounter, -ycounter, -zcounter); D3d_rotate_z(mat, minv, sign * radians); D3d_translate(mat, minv, xcounter, ycounter, zcounter); } else { printf("no action\n") ; } D3d_mat_mult_points (x[currentObj], y[currentObj], z[currentObj], mat, x[currentObj], y[currentObj], z[currentObj], points[currentObj] + 1) ; //the numpoints[currentObj]+1 is because we have stored //the center of the object at the arrays' end G_rgb(0, 0, 0); G_clear(); drawit(currentObj); } } }
int main(int argc, Char *argv[]) { boolean canbeplotted; boolean wasplotted = false; #ifdef MAC OSErr retcode; FInfo fndrinfo; #ifdef OSX_CARBON FSRef fileRef; FSSpec fileSpec; #endif #ifdef __MWERKS__ SIOUXSetTitle("\pPHYLIP: Drawtree"); #endif argv[0] = "Drawgram"; #endif grbg = NULL; progname = argv[0]; #ifndef X_DISPLAY_MISSING nargc=1; nargv=argv; #endif init(argc, argv); emboss_getoptions("fdrawgram",argc,argv); setup_environment(argv, &canbeplotted); user_loop(&canbeplotted); if (!((previewer == winpreview || previewer == xpreview || previewer == mac) && (winaction == quitnow))) { previewing = false; initplotter(spp,fontname); numlines = dotmatrix ? ((long)floor(yunitspercm * ysize + 0.5)/strpdeep) : 1; if (plotter != ibm) printf("\nWriting plot file ...\n"); drawit(fontname,&xoffset,&yoffset,numlines,root); finishplotter(); FClose(plotfile); wasplotted = true; printf("\nPlot written to file \"%s\"\n\n", pltfilename); } FClose(intree); #ifdef MAC if (plotter == pict && wasplotted){ #ifdef OSX_CARBON FSPathMakeRef((unsigned char *)pltfilename, &fileRef, NULL); FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL); FSpGetFInfo(&fileSpec, &fndrinfo); fndrinfo.fdType='PICT'; fndrinfo.fdCreator='MDRW'; FSpSetFInfo(&fileSpec, &fndrinfo); #else retcode=GetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); fndrinfo.fdType='PICT'; fndrinfo.fdCreator='MDRW'; retcode=SetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); #endif } if (plotter == lw && wasplotted){ #ifdef OSX_CARBON FSPathMakeRef((unsigned char *)pltfilename, &fileRef, NULL); FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL); FSpGetFInfo(&fileSpec, &fndrinfo); fndrinfo.fdType='TEXT'; FSpSetFInfo(&fileSpec, &fndrinfo); #else retcode=GetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); fndrinfo.fdType='TEXT'; retcode=SetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); #endif } #endif printf("Done.\n\n"); #ifdef WIN32 phyRestoreConsoleAttributes(); #endif embExit(); return 0; }
void imWindow::DisplayImage(unsigned char *im, int w, int h, int ls, int type, int nd, int s, double gam, int x, int y) { // save these for redraws int size = w*h; pixelType = type; if (pixelType == RGB24) size = size * 3; if (pixelType == DISPARITY) size = size * 2; // check the buffer if (bufSize < size) { if (pixelData) delete [] pixelData; pixelData = new unsigned char[size]; bufSize = size; } curSize = size; memcpy(pixelData, im, curSize); xoff = x; yoff = y; width = w; height = h; linesize = ls; skipw = s; ndisp = nd; if (gam != gamma) { gamma = gam; if (gam > 0.0 && gam < 1.0) { for (int i=0; i<256; i++) gamtab[i] = (int)(0.5 + 255.0 * pow((double)i/255.0, gam)); } } // image scaling, keeps aspect ratio while (height > dheight) { height = height / 2; yoff = yoff / 2; linesize *= 2; width = width / 2; skipw *= 2; xoff = xoff / 2; } while (width > dwidth) { width = width / 2; skipw *= 2; xoff = xoff / 2; height = height / 2; yoff = yoff / 2; linesize *= 2; } drawit(); }