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;
g3d_enable(G3D_CULL_FACE);
g3d_enable(G3D_LIGHTING);
g3d_enable(G3D_LIGHT0);
+
+ g3d_polygon_mode(shading);
}
static void update(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<sizeof mesh_car / sizeof mesh_car[0]; i++) {
- if(mesh_car[i].varr) {
- g3d_set_texture(tex_car[i].width, tex_car[i].height, tex_car[i].pixels);
+ g3d_light_color(0, 0.3, 0.3, 0.3);
+ g3d_push_matrix();
+ g3d_scale(1, -1, 1);
+ g3d_front_face(G3D_CW);
+ draw_mesh(&mesh_car[0]);
+ g3d_front_face(G3D_CCW);
+ g3d_pop_matrix();
- zsort_mesh(&mesh_car[i]);
- draw_mesh(&mesh_car[i]);
- }
- }
+ g3d_light_color(0, 1, 1, 1);
+ draw_mesh(&mesh_car[0]);
swap_buffers(fb_pixels);
}
static void keypress(int key)
{
+ static int lighting = 1;
+ static int clipping = 1;
+
+ switch(key) {
+ case ' ':
+ shading = (shading + 1) % 5;
+ g3d_polygon_mode(shading);
+ break;
+
+ case 'l':
+ lighting = !lighting;
+ if(lighting) {
+ g3d_enable(G3D_LIGHTING);
+ } else {
+ g3d_disable(G3D_LIGHTING);
+ }
+ break;
+
+ case 'c':
+ clipping = !clipping;
+ if(clipping) {
+ g3d_enable(G3D_CLIP_FRUSTUM);
+ } else {
+ g3d_disable(G3D_CLIP_FRUSTUM);
+ }
+ break;
+ }
}