diff options
author | Brian Paul <[email protected]> | 2005-01-09 17:37:50 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-01-09 17:37:50 +0000 |
commit | 92eddb0fd404624ca198f19e4088927701eec7f5 (patch) | |
tree | dd93d51d271e6bd43d09af9e8b0f3a98a640a8d2 /progs/demos/tunnel2.c | |
parent | 516f9bc6e306fe7820649ead125d557b46ca8419 (diff) |
better animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/demos/tunnel2.c')
-rw-r--r-- | progs/demos/tunnel2.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/progs/demos/tunnel2.c b/progs/demos/tunnel2.c index 436f01b3e49..14248c095c0 100644 --- a/progs/demos/tunnel2.c +++ b/progs/demos/tunnel2.c @@ -12,14 +12,14 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#include <time.h> +#include <string.h> #ifdef WIN32 #include <windows.h> #endif #include <GL/glut.h> -#include "readtex.c" +#include "readtex.h" #include "tunneldat.h" #ifdef FX @@ -51,11 +51,11 @@ static GLint Frames = 0; static float obs[3] = { 1000.0, 0.0, 2.0 }; static float dir[3]; -static float v = 0.5; +static float v = 30.; static float alpha = 90.0; static float beta = 90.0; -static int fog = 0; +static int fog = 1; static int bfcull = 1; static int usetex = 1; static int cstrip = 0; @@ -97,7 +97,7 @@ inittextures(void) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_NEAREST); + GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -158,6 +158,13 @@ drawobjs(const int *l, const float *f) static void calcposobs(void) { + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + dir[0] = sin(alpha * M_PI / 180.0); dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0); dir[2] = cos(beta * M_PI / 180.0); @@ -169,9 +176,9 @@ calcposobs(void) if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) dir[2] = 0; - obs[0] += v * dir[0]; - obs[1] += v * dir[1]; - obs[2] += v * dir[2]; + obs[0] += v * dir[0] * dt; + obs[1] += v * dir[1] * dt; + obs[2] += v * dir[2] * dt; } static void @@ -202,10 +209,10 @@ key(unsigned char k, int x, int y) break; case 'a': - v += 0.01; + v += 5.; break; case 'z': - v -= 0.01; + v -= 5.; break; #ifdef XMESA |