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/tunnel.c | |
parent | 516f9bc6e306fe7820649ead125d557b46ca8419 (diff) |
better animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/demos/tunnel.c')
-rw-r--r-- | progs/demos/tunnel.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/progs/demos/tunnel.c b/progs/demos/tunnel.c index f0faa61a0bf..a47b916d60d 100644 --- a/progs/demos/tunnel.c +++ b/progs/demos/tunnel.c @@ -9,14 +9,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 XMESA @@ -55,7 +55,7 @@ static int win = 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; @@ -84,7 +84,7 @@ inittextures(void) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_LINEAR); + GL_LINEAR_MIPMAP_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glGenTextures(1, &t2id); @@ -160,6 +160,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); @@ -171,9 +178,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 @@ -204,10 +211,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 |