FrameTimer::FrameTimer()
{
m_dwTotalFrames = 0L;
m_ulStartTime = 0;
m_ulTime = 0;
m_ulLastTime = 0;
}
FrameTimer::~FrameTimer()
{
}
void FrameTimer::Start()
{
// Get the start time, and store the last time
m_ulStartTime = timeGetTime();
m_ulLastTime = m_ulStartTime;
// Initialize the variables that hold data that we
// will be using.
m_fTimeForFrame = 0;
m_fElapsedTime = 0;
m_iAbsoluteTime = 0;
m_fFPS = 0;
m_fAvgFPS = 0;
// This variable holds how many seconds have passed since the last update
seconds = 0;
// This var holds the amount of frames passed in that time
dwNumFrames = 0;
}
void FrameTimer::Update()
{
// First increment the frame count. Because we are calling
// this function ONCE every frame, NOT MORE!
m_dwTotalFrames ++;
m_ulTime = timeGetTime();
m_fTimeForFrame = (float)(m_ulTime - m_ulLastTime)/ 1000.0f;
m_fElapsedTime = (float)(m_ulTime - m_ulStartTime)/1000.0f;
m_ulLastTime = m_ulTime;
m_iAbsoluteTime = (m_ulTime - m_ulStartTime)/1000;
// Calculate the total time uptil now. So just add on the elapsed time :)
m_fElapsedTime += m_fTimeForFrame;
// Increment the frame variable
dwNumFrames++;
// Add the frame time to teh seconds variable
seconds += m_fTimeForFrame;
// Check if one second has passed. If yes then
if( seconds >= 1.0f )
{
// Calculate FPS
m_fFPS = float( dwNumFrames / seconds );
// Restart the variables
seconds = 0;
dwNumFrames = 0;
// Calculate the average fps
m_fAvgFPS = (float)m_dwTotalFrames/(float)m_fElapsedTime;
}
}
Frame Rate stuck at 60 fps
Hi,
I'm new to DirectX and cannot figure out why my frame rate struggles to go over 60fps,
Here is my timer class which is updated once very frame, and the resulting fps is displayed on the screen?
Any idea why the frame rate will not go above 60??
Even when doing no work in between frames it stays around 60? Any help would be greatly appreciated.
Thanks in advance...
[Edited by - Muhammad Haggag on December 1, 2005 2:46:17 PM]
Hey,
don't you have vSync switched on? It's a common cause of FPS limitation.
Use d3dParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE instead of D3DPRESENT_INTERVAL_DEFAULT.
kp
don't you have vSync switched on? It's a common cause of FPS limitation.
Use d3dParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE instead of D3DPRESENT_INTERVAL_DEFAULT.
kp
Quote:Original post by kovacsp
Use d3dParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE instead of D3DPRESENT_INTERVAL_DEFAULT.
And if this doesn't help, make sure that you haven't forced VSync on in your video card drivers.
And if that doesnt help they say for every kick you give the computer 1 fps is added!!!
lol, hahaaa
Also if ur running in window mode u will have the slow down of copying the data bit for bit to the screen when u flip the buffer
lol, hahaaa
Also if ur running in window mode u will have the slow down of copying the data bit for bit to the screen when u flip the buffer
Use source tags, please. There's a sticky thread in this forum, please read it. There's also a Forum FAQ. And a GDNet Forums FAQ.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement