Jump to content
  • Advertisement
Sign in to follow this  
strokes

Frame Rate stuck at 60 fps

This topic is 4863 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

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?
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;
    }
}
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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!