Skip to main content
gamedev.net
🔒 Locked

Baffling Framerates

Started by mattm Feb 23, 2005 at 4:14 PM 4 replies 850+ views
Original Post
mattm
mattm
Hi, I am getting very confusing framerate; sometimes they are reporting as 65 frames a second (1 shader, about 1200 vertices) and other times (exactly the same scene and code etc) they report as 320!! My frame calculation is based on
float fCurrTime = (float)timeGetTime();
      float fDeltaTime = (fCurrTime - mfLastTime)*0.001f;
      cState* pCurrentState = mpStateManager->GetState();
      pCurrentState->ProcessFrame(fDeltaTime);
      mfLastTime = fCurrTime; 
and
TimeElapsed += dTime;

	if(TimeElapsed >= 1.0f)
	{
		FPS = (float)FrameCnt / TimeElapsed;

		sprintf(FPSString, "%f", FPS);
		//sprintf(FPSString, "%f", dTime);
		FPSString[8] = '\0'; // mark end of string

		TimeElapsed = 0.0f;
		FrameCnt    = 0;
	} 
any ideas? Thanks, Matt
Trip99
Trip99
I cannot see where dTime is defined. You have a fDeltaTime but no dTime. The general idea seems right though so the problem may be elsewhere. BTW: you do not need to null terminate a string created with sprintf as it does it itself.
------------------------See my games programming site at: www.toymaker.info
mattm
mattm
Sorry, the second piece of code is in a different class. dTime is simply the local incarnation of fDeltaTime in pCurrentState->ProcessFrame(fDeltaTime).
dma42
dma42
where do you increase the FrameCnt-variable?
mattm
mattm
Just above the code you can see..sorry :)

If i display the interval between frames this also changes between 0.003 to 0.004 and 0.015 -to 0.016, which ties in with the framerates reported. I even had one go where they started reporting 63 and jumped to about 350 before staying there!

This is really confusing!

Matt
dma42
dma42
May be you should use the functions QueryPerformanceCounter and QueryPerformanceFrequency instead of timeGetTime. (They are more accurate).

----
dma

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.