diff options
-rw-r--r-- | sdl/glframe.c | 9 | ||||
-rw-r--r-- | sdl/pyramid.c | 24 |
2 files changed, 18 insertions, 15 deletions
diff --git a/sdl/glframe.c b/sdl/glframe.c index fa6b461..da7800e 100644 --- a/sdl/glframe.c +++ b/sdl/glframe.c @@ -63,15 +63,18 @@ void get_camera_orientation(GLFrame *frame, M3DMatrix44f m) /* some of the code is unimplemented */ void apply_camera_transform(GLFrame *frame) { + /* XXX: rotation only, should passed in as a parameter */ + int rot_only = 0; + M3DMatrix44f m; get_camera_orientation(frame, m); glMultMatrixf(m); -#if 0 /* if Rotation only, then do not do the translation */ if (!rot_only) - glTranslatef(-v_location[0], -v_location[1], -v_location[2]); - + glTranslatef(-frame->v_location[0], -frame->v_location[1], -frame->v_location[2]); + +#if 0 gluLookAt(v_location[0], v_location[1], v_location[2], v_location[0] + v_forward[0], v_location[1] + v_forward[1], diff --git a/sdl/pyramid.c b/sdl/pyramid.c index 1d36870..c7fe00e 100644 --- a/sdl/pyramid.c +++ b/sdl/pyramid.c @@ -119,8 +119,8 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag) case SDLK_s: xRot += 5.0f; break; case SDLK_a: yRot -= 5.0f; break; case SDLK_d: yRot += 5.0f; break; - case SDLK_UP: move_forward(&camera, 0.1f); break; - case SDLK_DOWN: move_forward(&camera, -0.1f); break; + case SDLK_UP: move_forward(&camera, 0.5f); break; + case SDLK_DOWN: move_forward(&camera, -0.5f); break; case SDLK_LEFT: rotate_local_y(&camera, 0.1f); break; case SDLK_RIGHT: rotate_local_y(&camera, -0.1f); break; default: break; @@ -138,13 +138,13 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag) yRot += 5.0f; if (keys_held[SDLK_UP]) - move_forward(&camera, 0.01f); + move_forward(&camera, 0.05f); if (keys_held[SDLK_DOWN]) - move_forward(&camera, -0.01f); + move_forward(&camera, -0.05f); if (keys_held[SDLK_LEFT]) - rotate_local_y(&camera, 0.01f); + rotate_local_y(&camera, 0.02f); if (keys_held[SDLK_RIGHT]) - rotate_local_y(&camera, -0.01f); + rotate_local_y(&camera, -0.02f); } xRot = (GLfloat) ((const int) xRot % 360); @@ -186,7 +186,8 @@ void processEvents() /* XXX below code has to be placed here */ /* check for keys that are being constantly held */ - if (keys_held[SDLK_w] || keys_held[SDLK_s] || keys_held[SDLK_a] || keys_held[SDLK_d]) + if (keys_held[SDLK_w] || keys_held[SDLK_s] || keys_held[SDLK_a] || keys_held[SDLK_d] || + keys_held[SDLK_UP] || keys_held[SDLK_DOWN] || keys_held[SDLK_LEFT] || keys_held[SDLK_RIGHT]) { flag = !flag; keys(NULL, keys_held, flag); @@ -197,7 +198,7 @@ void processEvents() static void draw_ground(void) { - GLfloat fExtent = 20.0f; + GLfloat fExtent = 10.0f; GLfloat fStep = 0.5f; GLfloat y = -0.4f; GLfloat iLine; @@ -230,8 +231,10 @@ static void render(void) /* save the matrix state and do the rotations */ glPushMatrix(); - + /* apply camera transform, and draw the ground */ apply_camera_transform(&camera); + glColor3ub(255, 0, 255); + draw_ground(); /* move object back and do in place rotation */ glTranslatef(0.0f, 0.2f, -3.5f); @@ -302,9 +305,6 @@ static void render(void) /* restore the matrix state */ glPopMatrix(); - - glColor3ub(255, 0, 255); - draw_ground(); /* buffer swap */ SDL_GL_SwapBuffers(); |