6 static void cleanup(void);
7 static void start(void);
8 static void stop(void);
9 static void update(float dt);
10 static void draw(void);
11 static void reshape(int x, int y);
12 static void keyboard(int key, int pressed);
13 static void mouse(int bn, int pressed, int x, int y);
14 static void motion(int x, int y);
15 static void wheel(int dir);
17 struct game_screen game_screen = {
34 static struct cmesh *blkmesh;
35 static float cam_theta, cam_phi, cam_dist = 6;
36 static int bnstate[16];
37 static int prev_mx, prev_my;
41 if(!(blkmesh = cmesh_alloc())) {
44 if(cmesh_load(blkmesh, "data/noisecube.obj") == -1) {
45 fprintf(stderr, "failed to load block model\n");
48 cmesh_dump(blkmesh, "dump");
49 cmesh_dump_obj(blkmesh, "dump.obj");
53 static void cleanup(void)
58 static void start(void)
62 static void stop(void)
66 static void update(float dt)
70 static void draw(void)
72 glTranslatef(0, 0, -cam_dist);
73 glRotatef(cam_phi, 1, 0, 0);
74 glRotatef(cam_theta, 0, 1, 0);
79 static void reshape(int x, int y)
83 static void keyboard(int key, int pressed)
87 static void mouse(int bn, int pressed, int x, int y)
89 bnstate[bn] = pressed;
94 static void motion(int x, int y)
96 float dx = x - prev_mx;
97 float dy = y - prev_my;
102 cam_theta += dx * 0.5;
105 if(cam_phi < -90) cam_phi = -90;
106 if(cam_phi > 90) cam_phi = 90;
109 cam_dist += dy * 0.1;
110 if(cam_dist < 0) cam_dist = 0;
114 static void wheel(int dir)