1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| int drawGLScene( )
{
static GLint T0 = 0;
static GLint Frames = 0;
static GLfloat fps = 0;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode(GL_PROJECTION);
glPushMatrix();
gluOrtho2D(0,curwidth,0,curheight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0,-6);
/* Carré à afficher */
glBegin(GL_QUADS);
glVertex2f(1,1);
glVertex2f(1,-1);
glVertex2f(-1,-1);
glVertex2f(-1,1);
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
SDL_GL_SwapBuffers( );
Frames++;
GLint t = SDL_GetTicks();
if ( t - T0 >= 1000 )
{
GLfloat seconds = (t - T0) / 1000.0;
fps = Frames / seconds;
printf("%d frames in %f seconds = %f FPS\n",Frames,seconds,fps);
T0 = t;
Frames = 0;
}
return( TRUE );
} |
Partager