static int WIDTH = 640;
static int HEIGHT = 480;
-#define FRAME 50
+static GLint T0 = 0;
+static GLint Frames = 0;
+
#define DIMP 20.0
#define DIMTP 16.0
static float beta = 90.0;
static float
-gettime(void)
-{
- static clock_t told = 0;
- clock_t tnew, ris;
-
- tnew = clock();
-
- ris = tnew - told;
-
- told = tnew;
-
- return (ris / (float) CLOCKS_PER_SEC);
-}
-
-static float
vrnd(void)
{
return (((float) rand()) / RAND_MAX);
static void
drawfire(void)
{
- static int count = 0;
- static char frbuf[80];
+ static char frbuf[80] = "";
int j;
- float fr;
dojoy();
}
glEnd();
- if ((count % FRAME) == 0) {
- fr = gettime();
- sprintf(frbuf, "Frame rate: %f", FRAME / fr);
- }
-
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glutSwapBuffers();
- count++;
+ Frames++;
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ sprintf(frbuf, "Frame rate: %f", fps);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
static int WIDTH = 640;
static int HEIGHT = 480;
+static GLint T0;
+static GLint Frames;
+
#define MAX_LOD 9
#define TEX_SKY_WIDTH 256
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
-static float
-gettime(void)
-{
- static clock_t told = 0;
- clock_t tnew, ris;
-
- tnew = clock();
-
- ris = tnew - told;
-
- told = tnew;
-
- return (ris / (float) CLOCKS_PER_SEC);
-}
-
static void
calcposobs(void)
{
static void
draw(void)
{
- static int count = 0;
- static char frbuf[80];
+ static char frbuf[80] = "";
static GLfloat alpha = 0.0f;
static GLfloat beta = 0.0f;
- float fr;
+ static float fr = 0.0;
dojoy();
/* Help Screen */
- fr = gettime();
sprintf(frbuf,
"Frame rate: %0.2f LOD: %d Tot. poly.: %d Poly/sec: %.1f",
- 1.0 / fr, LODbias, totpoly, totpoly / fr);
+ fr, LODbias, totpoly, totpoly * fr);
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
glutSwapBuffers();
- count++;
+ Frames++;
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ fr = Frames / seconds;
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
int
static int WIDTH = 640;
static int HEIGHT = 480;
-#define FRAME 50
+static GLint T0 = 0;
+static GLint Frames = 0;
#define BASESIZE 7.5f
#define SPHERE_RADIUS 0.75f
static int joyavailable = 0;
static int joyactive = 0;
-static float
-gettime(void)
-{
- static float told = 0.0f;
- float tnew, ris;
-
- tnew = glutGet(GLUT_ELAPSED_TIME);
-
- ris = tnew - told;
-
- told = tnew;
-
- return ris / 1000.0;
-}
-
static void
calcposobs(void)
{
static void
draw(void)
{
- static int count = 0;
- static char frbuf[80];
- float fr;
+ static char frbuf[80] = "";
dojoy();
glPopMatrix();
- if ((count % FRAME) == 0) {
- fr = gettime();
- sprintf(frbuf, "Frame rate: %f", FRAME / fr);
- }
-
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glutSwapBuffers();
- count++;
+ Frames++;
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ sprintf(frbuf, "Frame rate: %f", fps);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
static void
static int WIDTH=640;
static int HEIGHT=480;
-#define FRAME 50
+static GLint T0 = 0;
+static GLint Frames = 0;
#define BASESIZE 10.0
static GLuint t1id,t2id;
static GLuint teapotdlist,basedlist,lightdlist;
-static float gettime(void)
-{
- static clock_t told=0;
- clock_t tnew,ris;
-
- tnew=clock();
-
- ris=tnew-told;
-
- told=tnew;
-
- return(ris/(float)CLOCKS_PER_SEC);
-}
-
static void calcposobs(void)
{
dir[0]=sin(alpha*M_PI/180.0);
static void draw(void)
{
- static int count=0;
- static char frbuf[80];
- float fr;
+ static char frbuf[80] = "";
dojoy();
drawlight2();
glPopMatrix();
- if((count % FRAME)==0) {
- fr=gettime();
- sprintf(frbuf,"Frame rate: %f",FRAME/fr);
- }
-
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glutSwapBuffers();
- count++;
+ Frames++;
+
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ sprintf(frbuf, "Frame rate: %f", fps);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
static void inittextures(void)
#define WIDTH 640
#define HEIGHT 480
-#define TSCALE 4
+static GLint T0 = 0;
+static GLint Frames = 0;
-#define FRAME 50
+#define TSCALE 4
#define FOV 85
static float alpha = 75.0;
static float beta = 90.0;
-static float
-gettime(void)
-{
- static clock_t told = 0;
- clock_t tnew, ris;
-
- tnew = clock();
-
- ris = tnew - told;
-
- told = tnew;
-
- return (ris / (float) CLOCKS_PER_SEC);
-}
-
static void
calcposobs(void)
{
static void
drawscene(void)
{
- static int count = 0;
- static char frbuf[80];
- float fr;
+ static char frbuf[80] = "";
dojoy();
drawterrain();
glPopMatrix();
- if ((count % FRAME) == 0) {
- fr = gettime();
- sprintf(frbuf, "Frame rate: %.3f", FRAME / fr);
- }
-
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glutSwapBuffers();
- count++;
+ Frames++;
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ sprintf(frbuf, "Frame rate: %f", fps);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
static void
GLenum gluerr;
if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
- fprintf(stderr, "Error loading Mnt.bin\n");
+ fprintf(stderr, "Error loading terrain.dat\n");
exit(-1);
}
fread(bufferter, 256 * 256, 1, FilePic);
}
}
-static float
-gettime(void)
-{
- static clock_t told = 0;
- clock_t tnew, ris;
-
- tnew = clock();
-
- ris = tnew - told;
-
- told = tnew;
-
- return (ris / (float) CLOCKS_PER_SEC);
-}
-
static void
calcposobs(void)
{
{
static char frbuf[80] = "";
int i;
- float fr, base, offset;
+ float base, offset;
dojoy();
glutSwapBuffers();
Frames++;
-
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 2000) {
static int WIDTHC1 = 640;
static int HEIGHTC1 = 480;
-#define FRAME 50
+static GLint T0 = 0;
+static GLint Frames = 0;
#define NUMBLOC 5
}
}
-static float
-gettime(void)
-{
- static clock_t told = 0;
- clock_t tnew, ris;
-
- tnew = clock();
-
- ris = tnew - told;
-
- told = tnew;
-
- return (ris / (float) CLOCKS_PER_SEC);
-}
-
static void
calcposobs(void)
{
static void
draw(void)
{
- static int count = 0;
- static char frbuf[80];
+ static char frbuf[80] = "";
int i;
- float fr, base, offset;
+ float base, offset;
dojoy();
glPopMatrix();
glPopMatrix();
- if ((count % FRAME) == 0) {
- fr = gettime();
- sprintf(frbuf, "Frame rate: %f", FRAME / fr);
- }
-
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
- count++;
+ Frames++;
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ sprintf(frbuf, "Frame rate: %f", fps);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
static void
glutInitWindowSize(WIDTHC0, HEIGHTC0);
glutInit(&ac, av);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
#ifdef FX
if (!fxMesaSelectCurrentBoard(0)) {