X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=5fb7b02275284dc5870a39d801e026a732161b0d;hb=e50e34cb3791268a6665e3970ed76d2ad0d7aed2;hp=52db999c73f487a487b76433690162f2d50786ca;hpb=06a83976694c970fcf42bfdfc91832e780ca4747;p=vrtris diff --git a/src/gamescr.c b/src/gamescr.c index 52db999..5fb7b02 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -1,3 +1,4 @@ +#include "opengl.h" #include "screen.h" #include "cmesh.h" @@ -31,6 +32,9 @@ struct game_screen game_screen = { }; static struct cmesh *blkmesh; +static float cam_theta, cam_phi, cam_dist = 6; +static int bnstate[16]; +static int prev_mx, prev_my; static int init(void) { @@ -41,6 +45,8 @@ static int init(void) fprintf(stderr, "failed to load block model\n"); return -1; } + cmesh_dump(blkmesh, "dump"); + cmesh_dump_obj(blkmesh, "dump.obj"); return 0; } @@ -63,6 +69,11 @@ static void update(float dt) static void draw(void) { + glTranslatef(0, 0, -cam_dist); + glRotatef(cam_phi, 1, 0, 0); + glRotatef(cam_theta, 0, 1, 0); + + cmesh_draw(blkmesh); } static void reshape(int x, int y) @@ -75,10 +86,29 @@ static void keyboard(int key, int pressed) static void mouse(int bn, int pressed, int x, int y) { + bnstate[bn] = pressed; + prev_mx = x; + prev_my = y; } static void motion(int x, int y) { + float dx = x - prev_mx; + float dy = y - prev_my; + prev_mx = x; + prev_my = y; + + if(bnstate[0]) { + cam_theta += dx * 0.5; + cam_phi += dy * 0.5; + + if(cam_phi < -90) cam_phi = -90; + if(cam_phi > 90) cam_phi = 90; + } + if(bnstate[2]) { + cam_dist += dy * 0.1; + if(cam_dist < 0) cam_dist = 0; + } } static void wheel(int dir)