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) {
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)
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)
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;
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; i<num-1; i++) {
++verts;
- regis_absv(verts->x, verts->y);
+ regis_absv(verts->x >> 16, verts->y >> 16);
}
regis_end_vector();
}