better FPS calculation
This commit is contained in:
parent
b8cc150836
commit
d49b34a233
|
@ -71,7 +71,9 @@ static int fullscreen = 1;
|
|||
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
|
||||
|
||||
|
@ -136,21 +138,6 @@ static float v = 0.0;
|
|||
static float alpha = -90.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)
|
||||
{
|
||||
|
@ -387,10 +374,8 @@ dojoy(void)
|
|||
static void
|
||||
drawfire(void)
|
||||
{
|
||||
static int count = 0;
|
||||
static char frbuf[80];
|
||||
static char frbuf[80] = "";
|
||||
int j;
|
||||
float fr;
|
||||
|
||||
dojoy();
|
||||
|
||||
|
@ -468,11 +453,6 @@ drawfire(void)
|
|||
}
|
||||
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);
|
||||
|
@ -499,7 +479,17 @@ drawfire(void)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ static int fullscreen = 1;
|
|||
static int WIDTH = 640;
|
||||
static int HEIGHT = 480;
|
||||
|
||||
static GLint T0;
|
||||
static GLint Frames;
|
||||
|
||||
#define MAX_LOD 9
|
||||
|
||||
#define TEX_SKY_WIDTH 256
|
||||
|
@ -195,21 +198,6 @@ inittextures(void)
|
|||
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)
|
||||
{
|
||||
|
@ -544,11 +532,10 @@ drawipers(int depth, int from)
|
|||
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();
|
||||
|
||||
|
@ -610,10 +597,9 @@ draw(void)
|
|||
|
||||
/* 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);
|
||||
|
@ -644,7 +630,16 @@ draw(void)
|
|||
|
||||
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
|
||||
|
|
|
@ -24,7 +24,8 @@ static int fullscreen = 1;
|
|||
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
|
||||
|
@ -94,21 +95,6 @@ static int showreflectmap = 1;
|
|||
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)
|
||||
{
|
||||
|
@ -622,9 +608,7 @@ updatemaps(void)
|
|||
static void
|
||||
draw(void)
|
||||
{
|
||||
static int count = 0;
|
||||
static char frbuf[80];
|
||||
float fr;
|
||||
static char frbuf[80] = "";
|
||||
|
||||
dojoy();
|
||||
|
||||
|
@ -657,11 +641,6 @@ draw(void)
|
|||
|
||||
glPopMatrix();
|
||||
|
||||
if ((count % FRAME) == 0) {
|
||||
fr = gettime();
|
||||
sprintf(frbuf, "Frame rate: %f", FRAME / fr);
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
|
@ -746,7 +725,17 @@ draw(void)
|
|||
|
||||
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
|
||||
|
|
|
@ -27,7 +27,8 @@ static int fullscreen=1;
|
|||
static int WIDTH=640;
|
||||
static int HEIGHT=480;
|
||||
|
||||
#define FRAME 50
|
||||
static GLint T0 = 0;
|
||||
static GLint Frames = 0;
|
||||
|
||||
#define BASESIZE 10.0
|
||||
|
||||
|
@ -65,20 +66,6 @@ static int joyactive=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);
|
||||
|
@ -339,9 +326,7 @@ static void dojoy(void)
|
|||
|
||||
static void draw(void)
|
||||
{
|
||||
static int count=0;
|
||||
static char frbuf[80];
|
||||
float fr;
|
||||
static char frbuf[80] = "";
|
||||
|
||||
dojoy();
|
||||
|
||||
|
@ -375,11 +360,6 @@ static void draw(void)
|
|||
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);
|
||||
|
@ -405,7 +385,18 @@ static void draw(void)
|
|||
|
||||
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)
|
||||
|
|
|
@ -38,9 +38,10 @@ static int fullscreen = 1;
|
|||
#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
|
||||
|
||||
|
@ -71,21 +72,6 @@ static float v = 15.0;
|
|||
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)
|
||||
{
|
||||
|
@ -360,9 +346,7 @@ dojoy(void)
|
|||
static void
|
||||
drawscene(void)
|
||||
{
|
||||
static int count = 0;
|
||||
static char frbuf[80];
|
||||
float fr;
|
||||
static char frbuf[80] = "";
|
||||
|
||||
dojoy();
|
||||
|
||||
|
@ -391,11 +375,6 @@ drawscene(void)
|
|||
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);
|
||||
|
@ -424,7 +403,17 @@ drawscene(void)
|
|||
|
||||
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
|
||||
|
@ -558,7 +547,7 @@ loadpic(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);
|
||||
|
|
|
@ -155,21 +155,6 @@ drawobjs(int *l, float *f)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -369,7 +354,7 @@ draw(void)
|
|||
{
|
||||
static char frbuf[80] = "";
|
||||
int i;
|
||||
float fr, base, offset;
|
||||
float base, offset;
|
||||
|
||||
dojoy();
|
||||
|
||||
|
@ -445,7 +430,6 @@ draw(void)
|
|||
glutSwapBuffers();
|
||||
|
||||
Frames++;
|
||||
|
||||
{
|
||||
GLint t = glutGet(GLUT_ELAPSED_TIME);
|
||||
if (t - T0 >= 2000) {
|
||||
|
|
|
@ -40,7 +40,8 @@ static int HEIGHTC0 = 480;
|
|||
static int WIDTHC1 = 640;
|
||||
static int HEIGHTC1 = 480;
|
||||
|
||||
#define FRAME 50
|
||||
static GLint T0 = 0;
|
||||
static GLint Frames = 0;
|
||||
|
||||
#define NUMBLOC 5
|
||||
|
||||
|
@ -167,21 +168,6 @@ drawobjs(int *l, float *f)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -409,10 +395,9 @@ dojoy(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();
|
||||
|
||||
|
@ -461,11 +446,6 @@ draw(void)
|
|||
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);
|
||||
|
@ -492,7 +472,17 @@ draw(void)
|
|||
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
|
||||
|
@ -564,7 +554,7 @@ main(int ac, char **av)
|
|||
glutInitWindowSize(WIDTHC0, HEIGHTC0);
|
||||
glutInit(&ac, av);
|
||||
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
|
||||
#ifdef FX
|
||||
if (!fxMesaSelectCurrentBoard(0)) {
|
||||
|
|
Loading…
Reference in New Issue