static uint16_t *lowres_pixels;
static int lowres_width, lowres_height;
+static int use_zbuf;
+
+
struct screen *polytest_screen(void)
{
return &scr;
{
g3d_matrix_mode(G3D_PROJECTION);
g3d_load_identity();
- g3d_perspective(50.0, 1.3333333, 0.5, 100.0);
+ g3d_perspective(50.0, 1.3333333, 1.0, 10.0);
g3d_enable(G3D_CULL_FACE);
g3d_enable(G3D_LIGHTING);
g3d_polygon_mode(G3D_GOURAUD);
g3d_enable(G3D_TEXTURE_2D);
+
+ g3d_clear_color(20, 30, 50);
}
static void update(void)
update();
- memset16(fb_pixels, PACK_RGB16(20, 30, 50), FB_WIDTH * FB_HEIGHT);
+ if(use_zbuf) {
+ g3d_clear(G3D_COLOR_BUFFER_BIT | G3D_DEPTH_BUFFER_BIT);
+ g3d_enable(G3D_DEPTH_TEST);
+ } else {
+ g3d_clear(G3D_COLOR_BUFFER_BIT);
+ g3d_disable(G3D_DEPTH_TEST);
+ }
+
g3d_matrix_mode(G3D_MODELVIEW);
g3d_load_identity();
draw_bsp(&torus_bsp, vdir[0], vdir[1], vdir[2]);
} else {
- zsort_mesh(&torus);
+ if(!use_zbuf) {
+ zsort_mesh(&torus);
+ }
draw_mesh(&torus);
}
+ /* show zbuffer */
+ /*{
+ int i;
+ for(i=0; i<FB_WIDTH*FB_HEIGHT; i++) {
+ unsigned int z = pfill_zbuf[i];
+ fb_pixels[i] = (z >> 5) & 0x7e0;
+ }
+ }*/
+
+ cs_dputs(fb_pixels, 140, 0, use_zbuf ? "zbuffer" : "zsort");
+
/*draw_mesh(&cube);*/
swap_buffers(fb_pixels);
}
use_bsp = !use_bsp;
printf("drawing with %s\n", use_bsp ? "BSP tree" : "z-sorting");
break;
+
+ case 'z':
+ use_zbuf = !use_zbuf;
+ printf("Z-buffer %s\n", use_zbuf ? "on" : "off");
+ break;
}
}