progs/demos: fix glut initialization calls
[mesa.git] / progs / demos / multiarb.c
index 451fd11efe12c68fc973b9eef4d42603639f04d3..82796a0c3f4f4341c96b2ebac2d5cfe5575886d8 100644 (file)
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <GL/glew.h>
 #include <GL/glut.h>
 
 #include "readtex.h"
@@ -26,6 +27,8 @@
 #define ANIMATE 10
 #define QUIT 100
 
+static GLint T0 = 0;
+static GLint Frames = 0;
 static GLboolean Animate = GL_TRUE;
 static GLint NumUnits = 1;
 static GLboolean TexEnabled[8];
@@ -104,6 +107,20 @@ static void Display( void )
    glPopMatrix();
 
    glutSwapBuffers();
+
+   Frames++;
+
+   {
+      GLint t = glutGet(GLUT_ELAPSED_TIME);
+      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;
+      }
+   }
 }
 
 
@@ -321,11 +338,11 @@ int main( int argc, char *argv[] )
 {
    GLint i;
 
-   glutInit( &argc, argv );
    glutInitWindowSize( 300, 300 );
-   glutInitWindowPosition( 0, 0 );
+   glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
    glutCreateWindow(argv[0] );
+   glewInit();
 
    Init( argc, argv );