Advertisement

FPS counter logic

Started by January 05, 2001 04:54 AM
7 comments, last by RealityMonster 23 years, 10 months ago
Hi Im tryig to imlement a FPS counter. Im finding the time taken to render 1 frame and then calculating fps from there. Is the way im doing it accurate? In Timer.cpp void CTimer::startFPSTimer() { m_fpsStartTime = CTimer::getTime(); } void CTimer::stopFPSTimer() { m_fpsStopTime = CTimer::getTime(); m_fps = (m_fpsStopTime - m_fpsStartTime); } float CTimer::getFPSTime() { return 1000/m_fps; } In the main program ..... cTimer.startFPSTimer(); // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene() if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) { done=TRUE; } else { SwapBuffers(hDC); cglCamera.updateMousePosition(); // Get mouse for Camera } cTimer.stopFPSTimer(); and i print cTimer.getFPSTime() in DrawGLScene() it gives me a frame rate of 50-60fps. But i wanted to know if this is the way to get the fps?.
also, when i turn off the display of text (using wgl outline fonts), my frame rate goes up from 20->60!!
Advertisement
There seems to be a problem with NeHe''s text loading tutorial.. I used to do it another way in Delphi, which was fast, efficient, & could be displayed using 16 bit depth without the tearing effects i get from the tutorial, however, after switching to programming in the windows api, this method has become unavailable.. maybe i''ll take the time to find out what the delphi method actually was, & convert it for use in the win api..

Concerning your FPS counter, it looks alrighteo to me.. =P

- Wav
Isn''t this seconds per frame not frames per second?

Pete
Think a minute, what kind of computer could do 50 second/frame Has to be a big time oldie ...

His results show us that it couldn''t be seconds/frame
(you can find me on IRC : #opengl on undernet)
m_fps is the time it took to render one frame.
Advertisement
m_fps is the time it took to render one frame.
1 frame --> m_fps (ms)
FPS = 1000/m_fps (frames/sec)

however wat im worried about is where i have positioned the startTimer and stopTimer. Im not very proficient in win32 programming and dont know if this is the right place to put them(pls check the first post for the code). Will windows messaging or something interfere and am i actually getting the true time to render one frame??
thanks for the comments..
put the begintimer right after the endtimer, so there is a full cycle
(you can find me on IRC : #opengl on undernet)
now why dint i think of that! Elegant solution Slayer. lemme try it out.

This topic is closed to new replies.

Advertisement