From: John Tsiombikas Date: Sun, 9 Apr 2017 22:51:27 +0000 (+0300) Subject: foo X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=regis;a=commitdiff_plain;h=bf31f77d497cefcc3f04d559f762a07ef9e5d3e5 foo --- diff --git a/test.c b/test.c index 72b6029..ba6c02d 100644 --- a/test.c +++ b/test.c @@ -19,7 +19,7 @@ int main(int argc, char **argv) int pg = 1; signal(SIGINT, sig); - x3d_projection(45.0, (WIDTH << 16) / HEIGHT, 65536 / 2, 65536 * 500); + x3d_projection(45, (WIDTH << 16) / HEIGHT, 65536 / 2, 65536 * 500); while(!done) { @@ -46,12 +46,33 @@ int main(int argc, char **argv) static void draw(void) { x3d_load_identity(); - x3d_translate(0, 0, X16INT(6)); + x3d_translate(0, 0, 8 << 16); x3d_rotate(X16INT(25), 65536, 0, 0); - x3d_rotate(tm << 10, 0, 65536, 0); + x3d_rotate(tm << 13, 0, 65536, 0); x3d_color_index(3); + x3d_begin(X3D_QUADS); + x3d_vertex(-65536, -65536, -65536); + x3d_vertex(65536, -65536, -65536); + x3d_vertex(65536, 65536, -65536); + x3d_vertex(-65536, 65536, -65536); + + x3d_vertex(65536, -65536, -65536); + x3d_vertex(65536, -65536, 65536); + x3d_vertex(65536, 65536, 65536); + x3d_vertex(65536, 65536, -65536); + + x3d_vertex(65536, -65536, 65536); + x3d_vertex(-65536, -65536, 65536); + x3d_vertex(-65536, 65536, 65536); + x3d_vertex(65536, 65536, 65536); + + x3d_vertex(-65536, -65536, 65536); + x3d_vertex(-65536, -65536, -65536); + x3d_vertex(-65536, 65536, -65536); + x3d_vertex(-65536, 65536, 65536); + x3d_end(); } static void sig(int s) diff --git a/x3d.c b/x3d.c index 53faa9b..1e9a8d0 100644 --- a/x3d.c +++ b/x3d.c @@ -45,6 +45,9 @@ static const int32_t *vertex_array; static unsigned short vertex_count; static uint8_t im_color_index; +static int32_t im_vertex[4 * 3]; +static short im_vcount; +static short im_mode; void x3d_projection(int fov, int32_t aspect, int32_t nearz, int32_t farz) @@ -241,6 +244,30 @@ static void proc_vertex(const int32_t *vin, pvec3 *vout) vout->z = tvert[2]; } +void x3d_begin(int mode) +{ + im_mode = mode; + im_vcount = 0; +} + +void x3d_end(void) +{ +} + +void x3d_vertex(int32_t x, int32_t y, int32_t z) +{ + int32_t *vptr = im_vertex + im_vcount * 3; + vptr[0] = x; + vptr[1] = y; + vptr[2] = z; + + im_vcount = (im_vcount + 1) % im_mode; + if(!im_vcount) { + x3d_vertex_array(im_mode, im_vertex); + x3d_draw(im_mode, im_mode); + } +} + void x3d_color_index(int cidx) { im_color_index = cidx; @@ -250,12 +277,12 @@ void x3d_color_index(int cidx) void draw_poly(int num, const pvec3 *verts, int color) { int i; - regis_abspos(verts[0].x, verts[0].y); + regis_abspos(verts[0].x >> 16, verts[0].y >> 16); regis_begin_vector(REGIS_BOUNDED); for(i=0; ix, verts->y); + regis_absv(verts->x >> 16, verts->y >> 16); } regis_end_vector(); } diff --git a/x3d.h b/x3d.h index 2b5ac2b..02fd3c3 100644 --- a/x3d.h +++ b/x3d.h @@ -26,6 +26,10 @@ void x3d_vertex_array(int count, const int32_t *ptr); int x3d_draw(int prim, int vnum); int x3d_draw_indexed(int prim, int count, uint16_t *ptr); +void x3d_begin(int mode); +void x3d_end(void); + +void x3d_vertex(int32_t x, int32_t y, int32_t z); void x3d_color_index(int cidx); #endif /* X3D_H_ */