#include <stdlib.h>
#include <string.h>
#include <GL/glut.h>
+#include <sys/time.h>
+#include <time.h>
#define COS(X) cos( (X) * 3.14159/180.0 )
#define SIN(X) sin( (X) * 3.14159/180.0 )
GLboolean IndexMode = GL_FALSE;
GLuint Ball;
GLenum Mode;
-GLfloat Zrot = 0.0, Zstep = 6.0;
+GLfloat Zrot = 0.0, Zstep = 180.0;
GLfloat Xpos = 0.0, Ypos = 1.0;
-GLfloat Xvel = 0.2, Yvel = 0.0;
+GLfloat Xvel = 2.0, Yvel = 0.0;
GLfloat Xmin = -4.0, Xmax = 4.0;
GLfloat Ymin = -3.8, Ymax = 4.0;
-GLfloat G = -0.1;
+GLfloat G = -9.8;
static GLuint
make_ball(void)
idle(void)
{
static float vel0 = -100.0;
+ static double t0 = -1.;
+ double t, dt;
+ t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
+ if (t0 < 0.)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
- Zrot += Zstep;
+ Zrot += Zstep*dt;
- Xpos += Xvel;
+ Xpos += Xvel*dt;
if (Xpos >= Xmax) {
Xpos = Xmax;
Xvel = -Xvel;
Xvel = -Xvel;
Zstep = -Zstep;
}
- Ypos += Yvel;
- Yvel += G;
+ Ypos += Yvel*dt;
+ Yvel += G*dt;
if (Ypos < Ymin) {
Ypos = Ymin;
if (vel0 == -100.0)
}
-
-
static void
idle (void)
{
int i;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
for (i = 0; i < number_of_gears; i++)
- g[i].angle += g[i].angular_velocity;
+ g[i].angle += g[i].angular_velocity * dt;
glutPostRedisplay();
}
ACOLOR = 0.800 0.500 0.200\r
ALENGTH = 6.000\r
AMOTORED = 1\r
-AANGULARVELOCITY = 2.000\r
+AANGULARVELOCITY = 90.000\r
ADIRECTION = 1\r
\r
ANAME = AXLE2\r
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include <string.h>
#include <GL/glut.h>
-#include "readtex.c" /* I know, this is a hack. */
+#include "readtex.h"
#define SPECULAR_TEXTURE_FILE "../images/reflect.rgb"
#define BASE_TEXTURE_FILE "../images/tile.rgb"
static GLboolean Animate = GL_TRUE;
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
-static GLfloat DXrot = 1.0, DYrot = 2.5;
+static GLfloat DXrot = 20.0, DYrot = 50.;
static GLfloat Black[4] = { 0, 0, 0, 0 };
static GLfloat White[4] = { 1, 1, 1, 1 };
static GLint Frames = 0;
-
-
static void Idle( 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;
+
if (Animate) {
- Xrot += DXrot;
- Yrot += DYrot;
+ Xrot += DXrot*dt;
+ Yrot += DYrot*dt;
glutPostRedisplay();
}
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include <time.h>
+#include <string.h>
#if defined (WIN32)|| defined(_WIN32)
#include <windows.h>
#include <GL/glut.h>
-#include "readtex.c"
+#include "readtex.h"
#ifdef XMESA
#include "GL/xmesa.h"
static GLfloat alpha = 0.0f;
static GLfloat beta = 0.0f;
static float fr = 0.0;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
dojoy();
drawipers(0, FROM_NONE);
glPopMatrix();
- alpha += 0.5f;
- beta += 0.3f;
+ alpha += 4.f * dt;
+ beta += 2.4f * dt;
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
}
static void draw ( 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;
+
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
glutSwapBuffers();
- step+=0.05;
+ step += dt;
}
static void idle_( void )
#define MEAN_VELOCITY 3.0
#define GRAVITY 2.0
-#define TIME_DELTA 0.025 /* The speed of time. */
/* Modeling units of ground extent in each X and Z direction. */
#define EDGE 12
float distance;
int i;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+
motion = 0;
for (i=0; i<numPoints; i++) {
distance = pointVelocity[i][0] * theTime;
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
}
motion = 1;
- pointTime[i] += TIME_DELTA;
+ pointTime[i] += dt;
}
- theTime += TIME_DELTA;
+ theTime += dt;
if (!motion && !spin) {
if (repeat) {
makePointList();
case 0:
makePointList();
break;
-#if GL_ARB_point_parameters
+#ifdef GL_ARB_point_parameters
case 1:
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
break;
case 5:
blend = 0;
break;
-#if GL_ARB_point_parameters
+#ifdef GL_ARB_point_parameters
case 6:
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
break;
#include <stdio.h>
#include <stdlib.h>
#include "GL/glut.h"
-#include "../util/showbuffer.c"
-#include "../util/readtex.c"
+#include "showbuffer.h"
+#include "readtex.h"
#define DEG2RAD (3.14159/180.0)
static void idle( void )
{
- spin += 2.0;
- yrot += 3.0;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+ spin += 60.0 * dt;
+ yrot += 90.0 * dt;
glutPostRedisplay();
}
static GLfloat Phi = 0.0;
-static void Idle(void)
+static void Idle( void )
{
- Phi += 0.1;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+ Phi += 3.0 * dt;
glutPostRedisplay();
}
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
-#include "../util/showbuffer.c"
+#include "showbuffer.h"
#if 0 /* change to 1 if you want to use the old SGIX extensions */
#undef GL_ARB_depth_texture
static void
Idle(void)
{
- Yrot += 5.0;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+ Yrot += 75.0 * dt;
/*LightLongitude -= 5.0;*/
glutPostRedisplay();
}
static GLUquadricObj *Quadric;
static GLuint Sphere;
static GLfloat LightPos[4] = {10.0, 10.0, 10.0, 1.0};
-static GLfloat Delta = 1.0;
-static GLint Mode = 0;
+static GLfloat Delta = 20.0;
+static GLint Mode = 4;
/*static GLfloat Blue[4] = {0.0, 0.0, 1.0, 1.0};*/
/*static GLfloat Gray[4] = {0.5, 0.5, 0.5, 1.0};*/
static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0};
-
-static void Idle( void )
+static void
+Idle(void)
{
- LightPos[0] += Delta;
- if (LightPos[0]>15.0)
- Delta = -1.0;
- else if (LightPos[0]<-15.0)
- Delta = 1.0;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+ LightPos[0] += Delta * dt;
+ if (LightPos[0]>15.0 || LightPos[0]<-15.0)
+ Delta = -Delta;
glutPostRedisplay();
}
#define MEAN_VELOCITY 3.0
#define GRAVITY 2.0
-#define TIME_DELTA 0.025 /* The speed of time. */
/* Modeling units of ground extent in each X and Z direction. */
#define EDGE 12
float distance;
int i;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+
motion = 0;
for (i=0; i<numPoints; i++) {
distance = pointVelocity[i][0] * theTime;
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
}
motion = 1;
- pointTime[i] += TIME_DELTA;
+ pointTime[i] += dt;
}
- theTime += TIME_DELTA;
+ theTime += dt;
if (!motion && !spin) {
if (repeat) {
makePointList();
static float obs[3] = { OBSSTARTX, heightMnt * 1.3, OBSSTARTY };
static float dir[3], v1[2], v2[2];
-static float v = 15.0;
+static float v = 900.0;
static float alpha = 75.0;
static float beta = 90.0;
calcposobs(void)
{
float alpha1, alpha2;
+ 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[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
v2[0] = sin(alpha2 * M_PI / 180.0);
v2[1] = cos(alpha2 * M_PI / 180.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;
if (obs[1] < 0.0)
obs[1] = 0.0;
exit(0);
break;
case 'a':
- v += 0.5;
+ v += 50.;
break;
case 'z':
- v -= 0.5;
+ v -= 50.;
break;
case 'p':
if (poutline) {
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include <string.h>
#include <GL/glut.h>
-#include "readtex.c" /* I know, this is a hack. */
+#include "readtex.h"
#define TEXTURE_FILE "../images/reflect.rgb"
static GLboolean Animate = GL_TRUE;
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
-static GLfloat DXrot = 1.0, DYrot = 2.5;
+static GLfloat DXrot = 50.0, DYrot = 125.0;
/* performance info */
static GLint T0 = 0;
static void Idle( 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;
+
if (Animate) {
- Xrot += DXrot;
- Yrot += DYrot;
+ Xrot += DXrot * dt;
+ Yrot += DYrot * dt;
glutPostRedisplay();
}
}
static void idle( void )
{
- Angle += 2.0;
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+ Angle += 120.0*dt;
glutPostRedisplay();
}
#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
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;
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);
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);
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
break;
case 'a':
- v += 0.01;
+ v += 5.;
break;
case 'z':
- v -= 0.01;
+ v -= 5.;
break;
#ifdef XMESA
#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
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;
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);
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);
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
break;
case 'a':
- v += 0.01;
+ v += 5.;
break;
case 'z':
- v -= 0.01;
+ v -= 5.;
break;
#ifdef XMESA