fps counter

Started by
2 comments, last by Pav3 22 years, 7 months ago
How do i make an fps counter with visual c and opengl?
**> ATi Rules! nvidia doesn''t...that simple! <**
Advertisement
You have to count the number of frames you draw in a static int for example

static int frames = 0;static DWORD lastTimeFPS = 0;    //time when the last calculation took placeDWORD curTime = timeGetTime();++frames;// Update the scene stats once per secondif( curTime - lastTimeFPS > 1000 ){       curFPS		= 1000 * frames / (float)(curTime - lastTimeFPS);       lastTimeFPS	= curTime;       frames		= 0;}  


You must call this code every time you have finished to redraw a frame, then it will update "curFPS" every second. This you could printf or draw to the screen. The core of the code is the timeGetTime(); You must therefore #include "mmsystem.h" and link with winmm.lib

Sorry for my extraordinary bad english

Edited by - cha Mithrandir on September 8, 2001 11:31:05 AM
that''s to say, you must manage your fps counter all by yourself, right?
quote:Original post by EddieCai
that''s to say, you must manage your fps counter all by yourself, right?



Yes.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.

This topic is closed to new replies.

Advertisement