Archived

This topic is now archived and is closed to further replies.

how do you know when you get the correct FPS?

This topic is 5507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just wrote a time class, that keeps track fps, pausing, etc, but i don't know if it displays the correct FPS. What my program has is 75-76, but my program still does nothing, the main loop is empty, except the fps counting process. If i run 3D Mark 2001, I can get about 100fps. I was thinking it's probably the vertical retrace, but when I run my program in an old computer, I got 30 (pentium 1 200MMX, 4MB video card, 64MB RAM). 30Hz? I don't think so. this is the code:
    
HRESULT CTime::FrameCount()
{
	static int framecount = 0;
	static INT64 lastcount = 0;
	INT64 newcount = 0;
	INT64 difference = 0;

	QueryPerformanceCounter( (LARGE_INTEGER*) &newcount);

	if (newcount == 0) return E_FAIL;

	framecount++;

	difference = newcount - lastcount;
	if (difference >= m_frequency)
	{
		m_framerate = framecount;
		framecount = 0;
		lastcount = newcount;
	}

	return S_OK;
}
    
oh m_frequency is this: QueryPerformanceFrequency( (LARGE_INTEGER*) &m_frequency);
My compiler generates one error message: "does not compile." [edited by - alnite on November 17, 2002 12:21:29 AM]

Share this post


Link to post
Share on other sites
surely you want to check if difference is greater than 1000 (or how ever many of the time units returned by QueryPerformanceCounter make up a second) so it will then tell you how many frames have been counted up over the last second.

Share this post


Link to post
Share on other sites
quote:
Original post by necromancer_df
surely you want to check if difference is greater than 1000 (or how ever many of the time units returned by QueryPerformanceCounter make up a second) so it will then tell you how many frames have been counted up over the last second.


QueryPerformanceFrequency returns the number of counts per second. that''s why I use difference >= m_frequency, it tells that one second has elapsed.


quote:
Original post by niyaw
sounds like you''re limited by vsync.



That''s what I thought. But is it possible to get 30fps, limited by vsync? I think it''s based on vertical refresh rate, which is mostly 60Hz. But 30? Tell me I''m wrong.



My compiler generates one error message: "does not compile."

Share this post


Link to post
Share on other sites
Just for comparison, this is how I did it and I know that this works:


  
#include <time.h>

//global variables

time_t time1;
int fps_counter=0;
int fps = 0;

void display()
{
if(fps_counter == 0)time1 = time(NULL);

// my drawing goes here


if(difftime(time(NULL) , time1) >= 1)
// has one second passed?

{
fps = fps_counter; //store current fps

fps_counter=0; // reset counter

}
else fps_counter++; //still counting

}


But I think your code is correct too. To check it, you may just set your monitors vsync to a higher or lower value. If your fps change, then your code works.

Share this post


Link to post
Share on other sites