diff options
Diffstat (limited to 'progs/demos/engine.c')
-rw-r--r-- | progs/demos/engine.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/progs/demos/engine.c b/progs/demos/engine.c index 6040a2f103..3cf311e778 100644 --- a/progs/demos/engine.c +++ b/progs/demos/engine.c @@ -5,12 +5,11 @@ * June 2006 */ -#define GL_GLEXT_PROTOTYPES - #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" #include "trackball.h" @@ -387,7 +386,10 @@ DrawPositionedPiston(const Engine *eng, float crankAngle) glPushMatrix(); glRotatef(-90, 1, 0, 0); glTranslatef(0, 0, pos); - DrawPiston(eng); + if (eng->PistonList) + glCallList(eng->PistonList); + else + DrawPiston(eng); glPopMatrix(); } @@ -555,7 +557,7 @@ SquareWithHole(float squareSize, float holeRadius) for (i = 0; i <= 360; i += 5) { const float x1 = holeRadius * cos(DEG_TO_RAD(i)); const float y1 = holeRadius * sin(DEG_TO_RAD(i)); - float x2, y2; + float x2 = 0.0F, y2 = 0.0F; if (i > 315 || i <= 45) { x2 = squareSize; y2 = squareSize * tan(DEG_TO_RAD(i)); @@ -962,6 +964,28 @@ Draw(void) glEnable(GL_TEXTURE_2D); } + /* also print out a periodic fps to stdout. useful for trying to + * figure out the performance impact of rendering the string above + * with glBitmap. + */ + { + 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; + } + } + + glutSwapBuffers(); } @@ -1288,6 +1312,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("OpenGL Engine Demo"); + glewInit(); glutReshapeFunc(Reshape); glutMouseFunc(Mouse); glutMotionFunc(Motion); |