X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosrtxon;a=blobdiff_plain;f=src%2Fparts%2Frtxonoff.c;h=bab4d98fd43b6382048e88f51a09ea7435dd7917;hp=4c5f35e1ea420e6f07a40b03a094c5208fe7afcc;hb=584c6161bb6f3f548d5e27bb7d6895a81375881e;hpb=4621a049a4889c5a6845a08e9c0a4d6634ab8556 diff --git a/src/parts/rtxonoff.c b/src/parts/rtxonoff.c index 4c5f35e..bab4d98 100644 --- a/src/parts/rtxonoff.c +++ b/src/parts/rtxonoff.c @@ -14,23 +14,29 @@ static int init(void); static void destroy(void); static void start(long trans_time); static void draw(void); +static void keypress(int key); static struct screen scr = { "rtxonoff", init, destroy, start, 0, - draw + draw, + keypress }; static float cam_theta = -29, cam_phi = 35; -static float cam_dist = 6; +static float cam_dist = 10; static const char *car_fname[2] = {"data/ldiablo.obj", 0}; static const char *cartex_fname[2] = {"data/ldiablo.png", 0}; static struct g3d_mesh mesh_car[2]; static struct pimage tex_car[2]; +static int shading = G3D_TEX_GOURAUD; +static int do_clip = 1; + + struct screen *rtxonoff_screen(void) { return &scr; @@ -45,6 +51,7 @@ static int init(void) if(!(tex_car[i].pixels = img_load_pixels(cartex_fname[i], &tex_car[i].width, &tex_car[i].height, IMG_FMT_RGB24))) { fprintf(stderr, "failed to load car texture: %s\n", cartex_fname[i]); + return -1; } convimg_rgb24_rgb16(tex_car[i].pixels, (unsigned char*)tex_car[i].pixels, tex_car[i].width, tex_car[i].height); @@ -60,6 +67,12 @@ static int init(void) static void destroy(void) { + int i; + + for(i=0; i<2; i++) { + free(mesh_car[i].varr); + free(mesh_car[i].iarr); + } } static void start(long trans_time) @@ -71,6 +84,8 @@ static void start(long trans_time) g3d_enable(G3D_CULL_FACE); g3d_enable(G3D_LIGHTING); g3d_enable(G3D_LIGHT0); + + g3d_polygon_mode(shading); } static void update(void) @@ -81,6 +96,7 @@ static void update(void) static void draw(void) { int i; + static float vdir[3]; float t = (float)time_msec / 16.0f; update(); @@ -93,16 +109,50 @@ static void draw(void) g3d_rotate(cam_phi, 1, 0, 0); g3d_rotate(cam_theta, 0, 1, 0); - g3d_polygon_mode(G3D_TEX_GOURAUD); + g3d_set_texture(tex_car[0].width, tex_car[0].height, tex_car[0].pixels); + zsort_mesh(&mesh_car[0]); - for(i=0; i