backported g3d changes:
[dosdemo] / src / polytest.c
index 2558389..0b05313 100644 (file)
@@ -16,6 +16,7 @@ static void destroy(void);
 static void start(long trans_time);
 static void draw(void);
 static void draw_lowres_raster(void);
+static void keypress(int key);
 static int gen_texture(struct pimage *img, int xsz, int ysz);
 
 static struct screen scr = {
@@ -23,7 +24,8 @@ static struct screen scr = {
        init,
        destroy,
        start, 0,
-       draw
+       draw,
+       keypress
 };
 
 static float cam_theta, cam_phi = 25;
@@ -33,7 +35,7 @@ static struct bsptree torus_bsp;
 
 static struct pimage tex;
 
-static int use_bsp = 1;
+static int use_bsp = 0;
 
 #define LOWRES_SCALE   10
 static uint16_t *lowres_pixels;
@@ -56,11 +58,13 @@ static int init(void)
                torus.varr[i].v *= 2.0;
        }
 
+       /*
        init_bsp(&torus_bsp);
        if(bsp_add_mesh(&torus_bsp, &torus) == -1) {
                fprintf(stderr, "failed to construct torus BSP tree\n");
                return -1;
        }
+       */
 
        gen_texture(&tex, 128, 128);
 
@@ -80,7 +84,9 @@ static void destroy(void)
        free(cube.varr);
        free(torus.varr);
        free(torus.iarr);
+       /*
        destroy_bsp(&torus_bsp);
+       */
 }
 
 static void start(long trans_time)
@@ -93,7 +99,8 @@ static void start(long trans_time)
        g3d_enable(G3D_LIGHTING);
        g3d_enable(G3D_LIGHT0);
 
-       g3d_polygon_mode(G3D_TEX_GOURAUD);
+       g3d_polygon_mode(G3D_GOURAUD);
+       g3d_enable(G3D_TEXTURE_2D);
 }
 
 static void update(void)
@@ -201,6 +208,16 @@ static void draw_lowres_raster(void)
        }
 }
 
+static void keypress(int key)
+{
+       switch(key) {
+       case 'b':
+               use_bsp = !use_bsp;
+               printf("drawing with %s\n", use_bsp ? "BSP tree" : "z-sorting");
+               break;
+       }
+}
+
 static int gen_texture(struct pimage *img, int xsz, int ysz)
 {
        int i, j;