diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-03-04 17:41:46 +0000 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-03-04 21:37:23 +0000 |
commit | 59311fb06c7bb20efe29ecdc237d0171ee959c0a (patch) | |
tree | 7eabd6994c169f086aeca91900eec5b60d99a51a /progs/trivial | |
parent | ac55db1d7d6cd58e49a033859d1d86a7dcf71d45 (diff) | |
download | external_mesa3d-59311fb06c7bb20efe29ecdc237d0171ee959c0a.zip external_mesa3d-59311fb06c7bb20efe29ecdc237d0171ee959c0a.tar.gz external_mesa3d-59311fb06c7bb20efe29ecdc237d0171ee959c0a.tar.bz2 |
clear-repeat: print fps, use 300x300 window size
Diffstat (limited to 'progs/trivial')
-rw-r--r-- | progs/trivial/clear-repeat.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/progs/trivial/clear-repeat.c b/progs/trivial/clear-repeat.c index 2b3873e..9c618d4 100644 --- a/progs/trivial/clear-repeat.c +++ b/progs/trivial/clear-repeat.c @@ -72,6 +72,24 @@ static void Draw(void) glClearColor((sin(f)+1)/2.0,(cos(f)+1)/2.0,0.5,1); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); + + { + static GLint T0 = 0; + static GLint Frames = 0; + GLint t = glutGet(GLUT_ELAPSED_TIME); + + Frames++; + + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); + T0 = t; + Frames = 0; + } + } + } glutPostRedisplay(); } @@ -91,7 +109,7 @@ int main(int argc, char **argv) exit(1); } - glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); type = GLUT_RGB | GLUT_ALPHA; type |= GLUT_DOUBLE; |