X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=blobdiff_plain;f=view.c;h=cc86803594841154686a48adb5c77aff1bb5b316;hp=cfa39753f1e89d29329ce115d1328c98c9914f57;hb=3c0d58c901fd6f8265dad93f096d2ae03866fc6e;hpb=62f97dcbc53754ef8a81add86946e54825c4c096 diff --git a/view.c b/view.c index cfa3975..cc86803 100644 --- a/view.c +++ b/view.c @@ -25,6 +25,7 @@ static GSL_MATRIX(transform); static FILE *input_f; static struct stat input_stab; static const char *input_filename; +static int pause_updates; static void read_input(void) { int r; @@ -84,9 +85,12 @@ static void generate_display_list(void) { * orientable so it shouldn't matter). Picking the parallelogram * to our right avoids getting it wrong at the join. */ +//if ((vb & YMASK) > Y1) continue; +//if ((vb & XMASK) > 2) continue; for (e=0; e=0); if (ve[5]>=0) addtriangle(vb,ve[0],ve[5]); +//continue; if (ve[1]>=0) addtriangle(vb,ve[1],ve[0]); } @@ -97,7 +101,7 @@ static void generate_display_list(void) { if (vertex_in_triangles[v] != expd) { fprintf(stderr,"vertex %02x used for %d triangles, expected %d\n", v, vertex_in_triangles[v], expd); - abort(); +// abort(); } } vertex_in_triangles_checked= 1; @@ -107,7 +111,7 @@ static void generate_display_list(void) { static int dl_compare(const void *tav, const void *tbv) { int i; const Triangle *const *tap= tav, *ta= *tap; - const Triangle *const *tbp= tbp, *tb= *tbp; + const Triangle *const *tbp= tbv, *tb= *tbp; double za=0, zb=0; for (i=0; i<3; i++) { za += ta->vertex[i][2]; @@ -148,7 +152,7 @@ static void drawtriangle(const Triangle *t) { int i; for (i=0; i<3; i++) { - double *v= t->vertex[i]; + const double *v= t->vertex[i]; double x= v[0]; double y= v[1]; double z= v[2]; @@ -170,7 +174,7 @@ static void drawtriangle(const Triangle *t) { static const unsigned long core_event_mask= ButtonPressMask|ButtonReleaseMask|StructureNotifyMask|ButtonMotionMask| - KeyPressMask; + KeyPressMask|SubstructureNotifyMask; static void mkpixmaps(void) { for (currentbuffer=0; currentbuffer<2; currentbuffer++) { @@ -550,16 +554,22 @@ static void event_key(XKeyEvent *e) { return; } - if (!strcmp(buf,"q")) exit(0); - if (!strcmp(buf,"w")) { + if (!strcmp(buf,"q")) + exit(0); + else if (!strcmp(buf,"p")) + pause_updates= !pause_updates; + else if (!strcmp(buf,"w")) { wireframe= !wireframe; show(); return; - } - if (!strcmp(buf,"d")) { + } else if (!strcmp(buf,"d")) { eyes_apart= eyes_apart>0 ? eyes_apart_min : eyes_apart_preferred; show(); return; + } else { + printf("unknown key keycode=%d state=0x%x char=%c 0x%02x\n", + e->keycode, e->state, buf[0]>' ' && buf[0]<127 ? buf[0] : '?', + buf[0]); } } @@ -655,8 +665,11 @@ int main(int argc, const char *const *argv) { polls[i].fd= ConnectionNumber(display); polls[i].events= wantedevents; - r= poll(polls, nxfds+1, motion_deferred ? 0 : 200); - if (r<0) diee("poll"); + r= poll(polls, nxfds+1, motion_deferred ? 0 : pause_updates ? -1 : 200); + if (r<0) { + if (errno==EINTR) continue; + diee("poll"); + } for (i=0; i