gba-x3dtest
diff src/game.c @ 13:2070a81127f2
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 23 Jun 2014 08:28:28 +0300 |
parents | ecc022a21279 |
children | c398d834d64a |
line diff
1.1 --- a/src/game.c Mon Jun 23 06:44:04 2014 +0300 1.2 +++ b/src/game.c Mon Jun 23 08:28:28 2014 +0300 1.3 @@ -5,6 +5,7 @@ 1.4 #include "sincos.h" 1.5 #include "fixed.h" 1.6 #include "palman.h" 1.7 +#include "ggen.h" 1.8 1.9 static void draw_rect(int x, int y, int w, int h, uint16_t color); 1.10 1.11 @@ -12,12 +13,24 @@ 1.12 #define X16FLT(x) ((int32_t)((x) * 65536.0)) 1.13 1.14 static const int32_t poly[] = { 1.15 - X16FLT(0), X16FLT(1), 0, 1.16 - X16FLT(1), X16FLT(-0.8), 0, 1.17 - X16FLT(-1), X16FLT(-0.5), 0 1.18 + X16INT(-1), X16INT(-1), 0, 1.19 + X16INT(-1), X16INT(1), 0, 1.20 + X16INT(1), X16INT(1), 0, 1.21 + X16INT(1), X16INT(-1), 0, 1.22 + X16INT(1), X16INT(-1), 0, 1.23 + X16INT(1), X16INT(1), 0, 1.24 + X16INT(-1), X16INT(1), 0, 1.25 + X16INT(-1), X16INT(-1), 0 1.26 +}; 1.27 +static const int32_t colors[] = { 1.28 + 65535, 0, 0, 65535, 0, 0, 65535, 0, 0, 65535, 0, 0, 1.29 + 65536, 65535, 0, 65536, 65535, 0, 65536, 65535, 0, 65536, 65535, 0 1.30 }; 1.31 static const short vcount = sizeof poly / sizeof *poly / 3; 1.32 1.33 +static struct mesh box; 1.34 + 1.35 + 1.36 int game_init(void) 1.37 { 1.38 sincos_init(); 1.39 @@ -27,9 +40,13 @@ 1.40 1.41 x3d_projection(45.0, (WIDTH << 16) / HEIGHT, 65536 / 2, 65536 * 500); 1.42 1.43 + init_mesh(&box); 1.44 + gen_box(&box); 1.45 + 1.46 return 0; 1.47 } 1.48 1.49 +static int32_t cam_theta, cam_phi = 25 << 16; 1.50 static short keyrot; 1.51 static int autorot = 1; 1.52 1.53 @@ -48,33 +65,33 @@ 1.54 } 1.55 x3d_translate(itox16(WIDTH / 2), itox16(HEIGHT / 2), 0);*/ 1.56 1.57 - if(autorot) { 1.58 - x3d_rotate((msec / 64) << 16, 0, 65536, 0); 1.59 - } else { 1.60 - x3d_rotate(keyrot << 16, 0, 65536, 0); 1.61 - } 1.62 - x3d_translate(0, 0, X16INT(2)); 1.63 - 1.64 - x3d_vertex_array(vcount, poly); 1.65 + x3d_rotate(cam_phi, 65536, 0, 0); 1.66 + x3d_rotate(keyrot << 16, 0, 65536, 0); 1.67 + x3d_translate(0, 0, X16INT(6)); 1.68 1.69 #ifdef PALMODE 1.70 x3d_color_index(255); 1.71 #else 1.72 x3d_color(65536, 65536, 65536); 1.73 #endif 1.74 - x3d_draw(X3D_TRIANGLES, vcount); 1.75 + 1.76 + draw_mesh(&box); 1.77 + 1.78 + /* 1.79 + x3d_vertex_array(vcount, poly); 1.80 + x3d_color_array(vcount, colors); 1.81 + x3d_draw(X3D_QUADS, vcount); 1.82 + x3d_color_array(0, 0); 1.83 1.84 #ifdef PALMODE 1.85 x3d_color_index(RGBPAL(0, 255, 0)); 1.86 #else 1.87 x3d_color(0, 65536, 0); 1.88 #endif 1.89 + 1.90 x3d_draw(X3D_POINTS, vcount); 1.91 x3d_vertex_array(0, 0); 1.92 - 1.93 - draw_rect(0, 0, WIDTH, HEIGHT, RGBPAL(255, 0, 0)); 1.94 - draw_rect(1, 1, WIDTH - 2, HEIGHT - 2, RGBPAL(0, 255, 0)); 1.95 - draw_rect(2, 2, WIDTH - 4, HEIGHT - 4, RGBPAL(32, 64, 255)); 1.96 + */ 1.97 1.98 flip(); 1.99 }