-/* $Id: clearspd.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Simple GLUT program to measure glClear() and glutSwapBuffers() speed.
* Brian Paul February 15, 1997 This file in public domain.
*/
-/*
- * $Log: clearspd.c,v $
- * Revision 1.1 1999/08/19 00:55:40 jtg
- * Initial revision
- *
- * Revision 3.3 1999/03/28 18:18:33 brianp
- * minor clean-up
- *
- * Revision 3.2 1999/03/18 08:16:34 joukj
- *
- * cmpstr needs string.h to included to avoid warnings
- *
- * Revision 3.1 1998/06/29 02:38:30 brianp
- * removed unneeded includes
- *
- * Revision 3.0 1998/02/14 18:42:29 brianp
- * initial rev
- *
- */
-
#include <stdio.h>
#include <stdlib.h>
glClear( BufferMask );
glutSwapBuffers();
}
+ glFinish();
t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
}
else {
for (i=0;i<Loops;i++) {
glClear( BufferMask );
}
+ glFinish();
t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
glutSwapBuffers();
}
+ /* NOTE: If clearspd doesn't map it's window immediately on
+ * starting, swaps will be istantaneous, so this will send Loops
+ * towards infinity. When a window is finally mapped, it may be
+ * minutes before the first call to glutSwapBuffers, making it look
+ * like there's a driver bug.
+ */
if (t1-t0 < MinPeriod) {
/* Next time do more clears to get longer elapsed time */
Loops *= 2;
clearRate = Loops / (t1-t0);
pixelRate = clearRate * Width * Height;
if (SwapFlag) {
- printf("Rate: %d clears+swaps in %gs = %g clears+swaps/s %d pixels/s\n",
- Loops, t1-t0, clearRate, (int)pixelRate );
+ printf("Rate: %d clears+swaps in %gs = %g clears+swaps/s %g pixels/s\n",
+ Loops, t1-t0, clearRate, pixelRate );
}
else {
- printf("Rate: %d clears in %gs = %g clears/s %d pixels/s\n",
- Loops, t1-t0, clearRate, (int)pixelRate);
+ printf("Rate: %d clears in %gs = %g clears/s %g pixels/s\n",
+ Loops, t1-t0, clearRate, pixelRate);
}
}
int main( int argc, char *argv[] )
{
+ GLint mode;
+
printf("For options: %s -help\n", argv[0]);
Init( argc, argv );
glutInitWindowSize( (int) Width, (int) Height );
glutInitWindowPosition( 0, 0 );
- glutInitDisplayMode( ColorMode | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_ACCUM );
+ mode = ColorMode | GLUT_DOUBLE;
+ if (BufferMask & GL_STENCIL_BUFFER_BIT)
+ mode |= GLUT_STENCIL;
+ if (BufferMask & GL_ACCUM_BUFFER_BIT)
+ mode |= GLUT_ACCUM;
+ if (BufferMask & GL_DEPTH_BUFFER_BIT)
+ mode |= GLUT_DEPTH;
+
+ glutInitDisplayMode(mode);
glutCreateWindow( argv[0] );