From fa1b447ef684e5eadda27d8870de6a6e09292a18 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 9 Dec 2016 15:50:15 -0600 Subject: bunch of stuff converted from triangle to shape --- hackvr.c | 566 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 296 insertions(+), 270 deletions(-) diff --git a/hackvr.c b/hackvr.c index dfc65ba..8868e15 100644 --- a/hackvr.c +++ b/hackvr.c @@ -20,15 +20,20 @@ int oldtime=0; int oldfps=0; int fps=0; +//TODO: optimizations +//TODO: store caches of cs_t, c2_t, and c3_t numbers. //TODO: don't forget to remake gophervr with this. +//TODO: XSegment or line structs to store some shit? //TODO: line and triangle intersection for finding what object was clicked on //if I don't do hiliting I only need to calculate that upon click. #define WALK_SPEED 1 #define SPLIT_SCREEN 2 #define CAMERA_SEPARATION 4 +#define RED_AND_BLUE 1 -#define TRIANGLES 16386 +#define SHAPES 16386 +#define MAX_SIDES 8 #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) @@ -99,18 +104,10 @@ struct c3_line { c3_t p2; }; -#define MAX_NGON 64 //why not? - -struct c3_polygon { - char *id; - c3_t p[MAX_NGON]; -}; - -struct c3_triangle {//use array or linked list? +struct c3_shape {//use array or linked list? char *id; - c3_t p1; - c3_t p2; - c3_t p3; + unsigned char len; + c3_t p[MAX_SIDES]; }; struct mainwin { @@ -154,15 +151,16 @@ struct mainwin { Pixmap cleanbackbuffer; GC gc; GC backgc; - struct c3_triangle *triangle[TRIANGLES]; - real tridist[TRIANGLES]; - int triangles; + struct c3_shape *shape[SHAPES]; + int shapes; int derp; int root_window; real split; } global; //used to figure out what c2 values are associated with each edge of the window. +//#define TOP 160.0 +//#define BOTTOM -160.0 #define TOP 240.0 #define BOTTOM -240.0 #define RIGHT 320.0 @@ -227,12 +225,15 @@ C b A (x1,y1) //I'll need this for collision I guess. /* + +//use this for finding a line that intersects with what the camera is pointing at c2_t get_c2_intersection(c2_t p1,real theta,c2_t p2) { real c; c=distance2(p1,p2); theta_a=C A B b = (c/1) * (theta_a + theta_offset) } + int get_2D_intersection_X(x1,y1,theta_offset,x2,y2) { int x3a,y3a,x3b,y3b; int a,b,c;//lenght of sides. @@ -331,10 +332,9 @@ c3_t rotate_c3_zr(c3_t p1,c3_t p2,real zr) {//rotate x and y around camera based return (c3_t){tmp.x,tmp.y,p1.z}; } -void rotate_triangle_yr(struct c3_triangle *t) {//changes input value! - t->p1=rotate_c3_yr(t->p1,camera.p,camera.yr); - t->p2=rotate_c3_yr(t->p2,camera.p,camera.yr); - t->p3=rotate_c3_yr(t->p3,camera.p,camera.yr); +void rotate_shape_yr(struct c3_shape *s) {//changes input value! + int i=0; + for(i=0;ilen;i++) s->p[0]=rotate_c3_yr(s->p[0],camera.p,camera.yr); } c2_t c3_to_c2(c3_t p3) { //DO NOT DRAW STUFF IN HERE @@ -343,6 +343,7 @@ c2_t c3_to_c2(c3_t p3) { //DO NOT DRAW STUFF IN HERE // c3_t tmp2; // c3_t tmp3; c3_t final; +//these rotations need to be about the previous axis after the axis itself has been rotated. final=rotate_c3_yr(p3,camera.p,d2r(camera.yr));//rotate everything around the camera's location. // final=rotate_c3_yr(p3,(c3_t){0,0,0},d2r(camera.yr));//rotate everything around the center no matter what. // tmp2=rotate_c3_xr(tmp1,camera.p,d2r(camera.xr)); @@ -379,38 +380,23 @@ cs_t c3_to_cs(c3_t p) { return c2_to_cs(c3_to_c2(p)); } -void XDrawTriangle(cs_t p1,cs_t p2,cs_t p3) { - //this is probably slower than drawing a triangle. - XPoint p[3]; - p[0]=(XPoint){p1.x,p1.y}; - p[1]=(XPoint){p2.x,p2.y}; - p[2]=(XPoint){p3.x,p3.y}; - XDrawLines(global.dpy,global.backbuffer,global.backgc,p,3,CoordModeOrigin); -// XDrawLine(global.dpy,global.backbuffer,global.backgc,p1.x,p1.y,p2.x,p2.y); -// XDrawLine(global.dpy,global.backbuffer,global.backgc,p2.x,p2.y,p3.x,p3.y); -// XDrawLine(global.dpy,global.backbuffer,global.backgc,p3.x,p3.y,p1.x,p1.y); -} - -void XDrawFilledTriangle(cs_t p1,cs_t p2,cs_t p3) { - XPoint p[3]; - p[0]=(XPoint){p1.x,p1.y};//should I just use XPoint instead of cs_t ? - p[1]=(XPoint){p2.x,p2.y}; - p[2]=(XPoint){p3.x,p3.y}; - XFillPolygon(global.dpy,global.backbuffer,global.backgc,p,3,Convex,CoordModeOrigin); -} - real shitdist2(c3_t p1,c3_t p2) { return sqrtl(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)) + ((p1.z - p2.z) * (p1.z - p2.z))); } -real shitdist(struct c3_triangle t,c3_t p) { +real shitdist(struct c3_shape s,c3_t p) { // apply rotation then find distance? - struct c3_triangle t_; - t_=t; - rotate_triangle_yr(&t_); - return (shitdist2(t_.p1,p) + shitdist2(t_.p2,p) + shitdist2(t_.p3,p)) / 3.0l; + int i; + struct c3_shape s_; + real total; + s_=s; + rotate_shape_yr(&s_); + for(i=0;ix1=x1; -//} -//void pushSquare() { -// pushTriangle(); -// pushTriangle(); -//} - typedef struct { - struct c3_triangle *t; + struct c3_shape *s; real d; } zsort_t; @@ -516,7 +515,7 @@ void draw_screen(Display *dpy,Window w,GC gc) { int direction,ascent,descent; char coords[256]; XGCValues gcval; - zsort_t zs[TRIANGLES]; + zsort_t zs[SHAPES]; XCopyArea(global.dpy,global.cleanbackbuffer,global.backbuffer,gc,0,0,global.width,global.height,0,0);//clear the backbuffer. // XCopyPlane(global.dpy,global.cleanbackbuffer,global.backbuffer,gc,0,0,global.width,global.height,0,0,1);//clear the backbuffer. @@ -534,21 +533,21 @@ void draw_screen(Display *dpy,Window w,GC gc) { } for(cn=0;cnid); + if(zs[0].s) { + strcpy(global.selected_object,zs[0].s->id); } - for(i=0;global.triangle[i];i++) { + for(i=0;global.shape[i];i++) { //now we pick the color of this triangle! if(global.red_and_blue) { if(cn==0) { @@ -640,34 +636,37 @@ void draw_screen(Display *dpy,Window w,GC gc) { } else { XSetForeground(global.dpy,global.backgc,global.blue.pixel); } +//tests of blending grayscale with red and blue +// draw_c3_triangle(*(zs[i].t)); } else { - if(!strcmp(global.selected_object,zs[i].t->id)) { + if(!strcmp(global.selected_object,zs[i].s->id)) { XSetForeground(global.dpy,global.backgc,global.green.pixel); } else { if(global.greyscale) { if(zs[i].d > 0) { - if(zs[i].d < 100) { + if(zs[i].d < 10) { colori=zs[i].d; } } - XSetForeground(global.dpy,global.backgc,global.colors[100-colori].pixel); + XSetForeground(global.dpy,global.backgc,global.colors[(int)(100.0-(colori * 10.0))].pixel); } } } - draw_c3_triangle(*(zs[i].t)); + draw_c3_shape(*(zs[i].s)); } XSetForeground(global.dpy, global.backgc, global.green.pixel); - snprintf(coords,sizeof(coords)-1,"selected object: %s",global.selected_object); - XTextExtents(font,coords,strlen(coords),&direction,&ascent,&descent,&overall); - XDrawString(global.dpy,global.backbuffer,global.backgc,global.xoff,global.height/2+(descent+0+ascent)*5,coords,strlen(coords)); - + if(global.debug) { + snprintf(coords,sizeof(coords)-1,"selected object: %s",global.selected_object); + XTextExtents(font,coords,strlen(coords),&direction,&ascent,&descent,&overall); + XDrawString(global.dpy,global.backbuffer,global.backgc,global.xoff,global.height/2+(descent+0+ascent)*5,coords,strlen(coords)); + } camera.p.z+=(global.split_flip)*(global.split*cosl(d2r(camera.yr+180))); camera.p.x+=(global.split_flip)*(global.split*sinl(d2r(camera.yr+180))); } - +//TODO: figure out what all this shit is and either update or remove. //DONT USE WIDTH for shit. /* x1=nextX(WIDTH/2,HEIGHT/2,d2r(camera.yr),40); @@ -728,7 +727,7 @@ char *read_line_hack(FILE *fp,int len) { char **line_splitter(char *line,int *rlen) { char **a; int len,i=0; - len=1; + len=1;//we're just counting how much we'll need the first loop through. for(i=0;line[i] && line[i] == ' ';i++);//skip leading space for(;line[i];len++) { for(;line[i] && line[i] != ' ';i++);//skip rest of data @@ -752,10 +751,18 @@ char **line_splitter(char *line,int *rlen) { return a; } +void set_aspect_ratio() { + XSizeHints *hints=XAllocSizeHints(); + hints->min_aspect.x=4*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)); + hints->min_aspect.y=3; + hints->max_aspect.x=4*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)); + hints->max_aspect.y=3; + hints->flags=PAspect; + XSetWMNormalHints(global.dpy,global.w,hints); +} int load_stdin() { - struct c3_triangle *to; - struct c3_triangle t; + struct c3_shape s; // struct c3_line l; char *command; char *line; @@ -770,10 +777,10 @@ int load_stdin() { //FD_ZERO(&master); //FD_ZERO(&readfs); //FD_SET(0,&master);//just stdin. - int i;//used to store the last triangle. + int i;//used to store the last triangle. even though I have a global for that. >_> // printf("# entering load_stdin()\n"); - for(i=0;global.triangle[i];i++) ;//hop to the end. + for(i=0;global.shape[i];i++) ;//hop to the end. fcntl(0,F_SETFL,O_NONBLOCK); if(feof(stdin)) { clearerr(stdin); @@ -787,170 +794,184 @@ int load_stdin() { // } // if(FD_ISSET(0,&readfs)) { while((line=read_line_hack(stdin,0))) {//load as long there's something to load -// while((line=read_line_hack(stdin,0))) {//load as long there's something to load - if(*line == '#') return 0; - //printf("# read command: %s\n",line); - a=line_splitter(line,&len); - if(len > 1) { - id=a[0]; - command=a[1]; - } else { - printf("Ohhhh. shit.\n"); - } -// for(i=0;iid,t.id)) { - // free(global.triangle[j]->id); - // free(global.triangle[j]); - global.triangle[j]=0; - } + if(*line == '#') return 0; + //printf("# read command: %s\n",line); + a=line_splitter(line,&len); + if(len > 1) { + id=a[0]; + command=a[1]; + } else { + printf("Ohhhh. shit.\n"); + return 0; + } + ret=1; + if(!strcmp(command,"deleteallexcept")) { + for(j=0;global.shape[j];j++) {//mark first. compress later. + if(strcmp(global.shape[j]->id,a[2])) {//TODO: memory leak! + //free(global.triangle[j]->id); + //free(global.triangle[j]); + global.shape[j]=0; } - l=0; - for(k=0;kid,s.id)) {//??? where is s.id supposed to be set from? + free(global.shape[j]->id); + free(global.shape[j]); + global.shape[j]=0; } - continue; } - if(!strcmp(command,"deletegroup")) { - for(j=0;global.triangle[j];j++) {//mark first. compress later. - if(!strcmp(global.triangle[j]->id,t.id)) { - free(global.triangle[j]->id); - free(global.triangle[j]); - global.triangle[j]=0; + l=0; + for(k=0;kid,a[2])) { + free(global.shape[j]->id); + global.shape[j]->id=strdup(id); } } - l=0; - for(k=0;kid,a[2])) { - free(global.triangle[j]->id); - global.triangle[j]->id=strdup(id); - } + continue; + } + if(!strcmp(command,"renamegroup")) { + if(len == 4) { + for(j=0;global.shape[j];j++) { + if(!strcmp(global.shape[j]->id,a[2])) { + free(global.shape[j]->id); + global.shape[j]->id=strdup(a[3]); } } - continue; } - if(!strcmp(command,"addtriangle")) { - if(len == 11) { - t.id=strdup(id); - t.p1.x=strtold(a[2],0);//second arg is just for a return value. set to 0 if you don't want it. - t.p1.y=strtold(a[3],0); - t.p1.z=strtold(a[4],0); - t.p2.x=strtold(a[5],0); - t.p2.y=strtold(a[6],0); - t.p2.z=strtold(a[7],0); - t.p3.x=strtold(a[8],0); - t.p3.y=strtold(a[9],0); - t.p3.z=strtold(a[10],0); -// printf("%s[%s]=(%d,%d,%d),(%d,%d,%d),(%d,%d,%d)t.p1.x",command,id,t.p1.x,t.p1.y,t.p1.z,t.p1.); - global.triangle[i]=malloc(sizeof(struct c3_triangle)); - to=global.triangle[i]; - memcpy(to,&t,sizeof(t)); - i++; - global.triangles=i; - global.triangle[i]=0; - } else { - printf("# ERROR: wrong amount of parts for addtriangle. got: %d expected: 11\n",len); + continue; + } + if(!strcmp(command,"export")) { + for(j=0;global.shape[j];j++) { + if(!strcmp(global.shape[j]->id,a[2])) { +// to=global.shape[j]; +// printf("%s addshape %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf\n",a[2], +// to->p1.x,to->p1.y,to->p1.z, +// to->p2.x,to->p2.y,to->p2.z, +// to->p3.x,to->p3.y,to->p3.z +// ); } + } + continue; + } + if(!strcmp(command,"dump")) { + printf("%s set camera.p.x %Lf\n",global.user,camera.p.x); + printf("%s set camera.p.y %Lf\n",global.user,camera.p.y); + printf("%s set camera.p.z %Lf\n",global.user,camera.p.z); + printf("%s set camera.xr %d\n",global.user,camera.xr); + printf("%s set camera.yr %d\n",global.user,camera.yr); + printf("%s set camera.zr %d\n",global.user,camera.zr); + printf("%s set camera.zoom %Lf\n",global.user,camera.zoom); + continue; + } + if(!strcmp(command,"quit")) { + return -1; + } + if(!strcmp(command,"set")) { //set variable //TODO: add more things to this. + if(len != 3 && len != 4) continue; + if(len == 4) { + if(!strcmp(a[2],"camera.p.x")) camera.p.x=strtold(a[3],0); + else if(!strcmp(a[2],"camera.p.y")) camera.p.y=strtold(a[3],0); + else if(!strcmp(a[2],"camera.p.z")) camera.p.z=strtold(a[3],0); + else if(!strcmp(a[2],"camera.zoom")) camera.zoom=strtold(a[3],0); + else if(!strcmp(a[2],"camera.xr")) camera.xr=atoi(a[3]); + else if(!strcmp(a[2],"camera.yr")) camera.yr=atoi(a[3]); + else if(!strcmp(a[2],"camera.zr")) camera.zr=atoi(a[3]); + else printf("# unknown variable: %s\n",a[2]); continue; - //return ret; } - if(!strcmp(command,"scaleup")) { - for(i=0;global.triangle[i];i++) { - if(!strcmp(global.triangle[i]->id,t.id)) { - global.triangle[i]->p1.x*=t.p1.x; - global.triangle[i]->p1.y*=t.p1.x; - global.triangle[i]->p1.z*=t.p1.x; - - global.triangle[i]->p2.x*=t.p1.x; - global.triangle[i]->p2.y*=t.p1.x; - global.triangle[i]->p2.z*=t.p1.x; - - global.triangle[i]->p3.x*=t.p1.x; - global.triangle[i]->p3.y*=t.p1.x; - global.triangle[i]->p3.z*=t.p1.x; + if(!strcmp(a[2],"force_redraw")) global.force_redraw^=1; + else if(!strcmp(a[2],"red_and_blue")) { global.red_and_blue^=1; set_aspect_ratio(); } + else { printf("# unknown variable: %s\n",a[2]); continue; } + printf("# %s toggled!\n",a[2]); + continue; + } + if(!strcmp(command,"addshape")) { + if(len > 3) { + global.shape[i]=malloc(sizeof(struct c3_shape)); + global.shape[i]->id=strdup(id); + global.shape[i]->len=strtold(a[2],0); + for(j=0;j < global.shape[i]->len;j++) { + global.shape[i]->p[j].x=strtold(a[(j*3)+3],0);//second arg is just for a return value. set to 0 if you don't want it. + global.shape[i]->p[j].y=strtold(a[(j*3)+4],0); + global.shape[i]->p[j].z=strtold(a[(j*3)+5],0); + } + i++; + global.shapes=i; + global.shape[i]=0; + } else { + printf("# ERROR: wrong amount of parts for addshape. got: %d expected: 11\n",len); + } + continue; + } + if(!strcmp(command,"scaleup")) {//should this scale separately so it can be a deform too? + for(i=0;global.shape[i];i++) { + if(!strcmp(global.shape[i]->id,id)) { + for(j=0;j < global.shape[i]->len;j++) { + global.shape[i]->p[j].x*=strtold(a[2],0); + global.shape[i]->p[j].y*=strtold(a[2],0); + global.shape[i]->p[j].z*=strtold(a[2],0); } } - continue; - //return ret; } - - if(!strcmp(command,"move")) {// extra fun if the arguments are different. - t.id=strdup(id); - if(len == 11) { - t.p1.x=strtold(a[2],0);//second arg is just for a return value. set to 0 if you don't want it. - t.p1.y=strtold(a[3],0); - t.p1.z=strtold(a[4],0); - t.p2.x=strtold(a[5],0); - t.p2.y=strtold(a[6],0); - t.p2.z=strtold(a[7],0); - t.p3.x=strtold(a[8],0); - t.p3.y=strtold(a[9],0); - t.p3.z=strtold(a[10],0); - for(i=0;global.triangle[i];i++) { - if(!strcmp(global.triangle[i]->id,t.id)) { - global.triangle[i]->p1.x+=t.p1.x; - global.triangle[i]->p1.y+=t.p1.y; - global.triangle[i]->p1.z+=t.p1.z; - global.triangle[i]->p2.x+=t.p1.x; - global.triangle[i]->p2.y+=t.p1.y; - global.triangle[i]->p2.z+=t.p1.z; - global.triangle[i]->p3.x+=t.p1.x; - global.triangle[i]->p3.y+=t.p1.y; - global.triangle[i]->p3.z+=t.p1.z; -/* - global.triangle[i]->p2.x+=t.p2.x; - global.triangle[i]->p2.y+=t.p2.y; - global.triangle[i]->p2.z+=t.p2.z; - global.triangle[i]->p3.x+=t.p3.x; - global.triangle[i]->p3.y+=t.p3.y; - global.triangle[i]->p3.z+=t.p3.z; -*/ + continue; + //return ret; + } + if(!strcmp(command,"move")) { + if(len > 4) { + for(i=0;global.shape[i];i++) { + if(!strcmp(global.shape[i]->id,id)) { + for(j=0;j < global.shape[i]->len;j++) { + global.shape[i]->p[j].x+=strtold(a[2],0); + global.shape[i]->p[j].y+=strtold(a[3],0); + global.shape[i]->p[j].z+=strtold(a[4],0); } } } - else { - printf("# ERROR: wrong amount of parts for move. got: %d expected: 11\n",len); - } - continue; - //return ret; } - printf("# I don't know what command you're talking about. %s\n",command); + else { + printf("# ERROR: wrong amount of parts for move. got: %d expected: 11\n",len); + } + continue; + //return ret; + } + printf("# I don't know what command you're talking about. %s\n",command); /* if(!strcmp(command,"rotate")) { - for(i=0;global.triangle[i];i++) { - global.triangle[i]->p1=rotate_c3_about() - global.triangle[i]->p2= - global.triangle[i]->p3= + for(i=0;global.shape[i];i++) { + global.shape[i]->p1=rotate_c3_about() + global.shape[i]->p2= + global.shape[i]->p3= } - }*/ - free(line); - if(a) free(a); -// } +*/ + free(line); + if(a) free(a); } -// printf("# leaving load_stdin()\n"); return ret; } -int export_file(FILE *fp) {//not used yet. maybe export in obj optionally? - struct c3_triangle *to; - int i; - for(i=0;global.triangle[i];i++) { - to=global.triangle[i]; - printf("%s addtriangle %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf\n",to->id,to->p1.x,to->p1.y,to->p1.z,to->p2.x,to->p2.y,to->p2.z,to->p3.x,to->p3.y,to->p3.z); - } +int export_file(FILE *fp) {//not used yet. maybe export in obj optionally? no. that should be an external program +// struct c3_shape *to; +// int i; +// for(i=0;global.shape[i];i++) { +// to=global.shape[i]; +// printf("%s addshape %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf\n",to->id,to->p1.x,to->p1.y,to->p1.z,to->p2.x,to->p2.y,to->p2.z,to->p3.x,to->p3.y,to->p3.z); +// } return 0; } @@ -1074,9 +1095,9 @@ int keypress_handler(int sym) { return 1; } + int main(int argc,char *argv[]) { Cursor cursor; - Window w; XEvent e; XSetWindowAttributes attributes; Window root,child;//why do I have this? @@ -1110,31 +1131,24 @@ int main(int argc,char *argv[]) { global.split_flip=-1; global.split=5; global.root_window=0; - global.red_and_blue=0; + global.red_and_blue=RED_AND_BLUE; //global.colors[0]=BlackPixel(global.dpy,DefaultScreen(global.dpy)); // int whiteColor = //WhitePixel(global.dpy, DefaultScreen(global.dpy)); attributes.background_pixel=global.colors[0].pixel; if(global.root_window) { - w = DefaultRootWindow(global.dpy); //this is still buggy. + global.w = DefaultRootWindow(global.dpy); //this is still buggy. } else { - w = XCreateWindow(global.dpy,DefaultRootWindow(global.dpy),0,0,WIDTH*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)),HEIGHT,1,DefaultDepth(global.dpy,DefaultScreen(global.dpy)),InputOutput,DefaultVisual(global.dpy,DefaultScreen(global.dpy))\ + global.w = XCreateWindow(global.dpy,DefaultRootWindow(global.dpy),0,0,WIDTH*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)),HEIGHT,1,DefaultDepth(global.dpy,DefaultScreen(global.dpy)),InputOutput,DefaultVisual(global.dpy,DefaultScreen(global.dpy))\ ,CWBackPixel, &attributes); - XSizeHints *hints=XAllocSizeHints(); - hints->min_aspect.x=4*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)); - hints->min_aspect.y=3; - hints->max_aspect.x=4*(global.split_screen / (global.red_and_blue ? global.split_screen : 1)); - hints->max_aspect.y=3; - hints->flags=PAspect; - XSelectInput(global.dpy, w, PointerMotionMask|StructureNotifyMask|ButtonPressMask|ButtonReleaseMask|KeyPressMask|ExposureMask); - XSetWMNormalHints(global.dpy,w,hints); + set_aspect_ratio(); + XSelectInput(global.dpy, global.w, PointerMotionMask|StructureNotifyMask|ButtonPressMask|ButtonReleaseMask|KeyPressMask|ExposureMask); } - XMapWindow(global.dpy, w); - XStoreName(global.dpy,w,"hackvr"); - global.w=w; + XMapWindow(global.dpy, global.w); + XStoreName(global.dpy,global.w,"hackvr"); global.greyscale=1; global.zsort=1; - global.triangle[0]=0;//we'll allocate as we need more. - global.gc=XCreateGC(global.dpy, w, 0, 0); + global.shape[0]=0;//we'll allocate as we need more. + global.gc=XCreateGC(global.dpy, global.w, 0, 0); if(global.red_and_blue) { global.width=WIDTH; @@ -1143,14 +1157,14 @@ int main(int argc,char *argv[]) { } global.height=HEIGHT; - global.backbuffer=XCreatePixmap(global.dpy,w,global.width,global.height,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); - global.cleanbackbuffer=XCreatePixmap(global.dpy,w,global.width,global.height,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); + global.backbuffer=XCreatePixmap(global.dpy,global.w,global.width,global.height,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); + global.cleanbackbuffer=XCreatePixmap(global.dpy,global.w,global.width,global.height,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); //backbuffer is uninitialized global.backgc=XCreateGC(global.dpy,global.backbuffer,0,0); cursor=XCreateFontCursor(global.dpy,XC_crosshair); - XDefineCursor(global.dpy, w, cursor); + XDefineCursor(global.dpy, global.w, cursor); XAllocNamedColor(global.dpy, global.color_map, "green", &global.green, &global.green); XAllocNamedColor(global.dpy, global.color_map, "red", &global.red, &global.red); @@ -1168,7 +1182,7 @@ int main(int argc,char *argv[]) { // XSetForeground(global.dpy, gc, whiteColor); // this was taking a "long" time. printf("# generating sky... "); - skypixmap=XCreatePixmap(global.dpy,w,SKYW,SKYH,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); + skypixmap=XCreatePixmap(global.dpy,global.w,SKYW,SKYH,DefaultDepth(global.dpy,DefaultScreen(global.dpy))); for(i=0;i