X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Fpolytest.c;h=f1835d4f4e57c21d5d5cff60da81fe182c7a9d4a;hb=9bdd6ddccd850f8a7dd2942c0b7088b77f41af0e;hp=a2985dd99a7c8a4198f187b083fa110cee8d0410;hpb=90a1ba8903eed9e3d4b17f4b56cd02ed801dd8b6;p=dosdemo diff --git a/src/polytest.c b/src/polytest.c index a2985dd..f1835d4 100644 --- a/src/polytest.c +++ b/src/polytest.c @@ -20,7 +20,6 @@ static void draw(void); static void draw_mesh(struct mesh *mesh); static int gen_cube(struct mesh *mesh, float sz); static int gen_torus(struct mesh *mesh, float rad, float ringrad, int usub, int vsub); -static int dump_obj(const char *fname, struct mesh *m); static void zsort(struct mesh *m); static struct screen scr = { @@ -42,13 +41,14 @@ static int init(void) { gen_cube(&cube, 1.0); gen_torus(&torus, 1.0, 0.25, 24, 12); - dump_obj("torus.obj", &torus); return 0; } static void destroy(void) { free(cube.varr); + free(torus.varr); + free(torus.iarr); } static void start(long trans_time) @@ -84,12 +84,14 @@ static void draw(void) g3d_matrix_mode(G3D_MODELVIEW); g3d_load_identity(); - g3d_translate(0, 0, -5); + g3d_translate(0, 0, -3); g3d_rotate(phi, 1, 0, 0); g3d_rotate(theta, 0, 1, 0); - zsort(&torus); - draw_mesh(&torus); + /*zsort(&torus);*/ + draw_mesh(&cube); + + swap_buffers(fb_pixels); } static void draw_mesh(struct mesh *mesh) @@ -249,50 +251,6 @@ static int gen_torus(struct mesh *mesh, float rad, float ringrad, int usub, int return 0; } -static int dump_obj(const char *fname, struct mesh *m) -{ - int i, j, nfaces; - FILE *fp; - struct g3d_vertex *vptr; - int16_t *iptr; - - if(!(fp = fopen(fname, "wb"))) { - return -1; - } - - nfaces = m->icount / m->prim; - printf("dumping obj: %s - %d vertices / %d faces (%d indices)\n", fname, - m->vcount, nfaces, m->icount); - - vptr = m->varr; - for(i=0; ivcount; i++) { - fprintf(fp, "v %f %f %f\n", vptr->x, vptr->y, vptr->z); - ++vptr; - } - vptr = m->varr; - for(i=0; ivcount; i++) { - fprintf(fp, "vn %f %f %f\n", vptr->nx, vptr->ny, vptr->nz); - ++vptr; - } - vptr = m->varr; - for(i=0; ivcount; i++) { - fprintf(fp, "vt %f %f\n", vptr->u, vptr->v); - ++vptr; - } - - iptr = m->iarr; - for(i=0; iicount; i += m->prim) { - fputc('f', fp); - for(j=0; jprim; j++) { - int idx = *iptr++ + 1; - fprintf(fp, " %d/%d/%d", idx, idx, idx); - } - fputc('\n', fp); - } - - fclose(fp); - return 0; -} static struct { struct g3d_vertex *varr;