Jump to content
  • Advertisement

Archived

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

DirectXXX

performance counter giving unexpected results

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

below is my fps code. When get fps from GetFPS(float* fps) the float output is a intger numbers -4543543 +523454 ets CFrameTimer::CFrameTimer(void) { m_lastUpdate = 0; m_fpsUpdateInterval = 0.5f; m_numFrames = 0; m_fps = 0; // We need to know how often the clock is updated if( !QueryPerformanceFrequency((LARGE_INTEGER *)&m_ticksPerSecond) ) m_ticksPerSecond = 1000; // If timeAtGameStart is 0 then we get the time since // the start of the computer when we call GetGameTime() m_timeAtGameStart = 0; m_timeAtGameStart = GetGameTime(); } // Called every time you need the current game time float CFrameTimer::GetGameTime() { UINT64 ticks; float time; // This is the number of clock ticks since start if( !QueryPerformanceCounter((LARGE_INTEGER *)&ticks) ) ticks = (UINT64)timeGetTime(); // Divide by frequency to get the time in seconds time = (float)(__int64)ticks/(float)(__int64)m_ticksPerSecond; // Subtract the time at game start to get // the time since the game started time -= m_timeAtGameStart; return time; } // Called once for every frame void CFrameTimer::UpdateFPS() { m_numFrames++; float currentUpdate = GetGameTime(); if( currentUpdate - m_lastUpdate > m_fpsUpdateInterval ) { m_fps = m_numFrames / (currentUpdate - m_lastUpdate); m_lastUpdate = currentUpdate; m_numFrames = 0; } } void CFrameTimer::GetFPS(float* fps) { *fps = m_fps; }

Share this post


Link to post
Share on other sites
Advertisement
Instead of using INT64 and __int64, and casting to LARGE_INTEGER, just declare your variables of type LARGE_INTEGER. When you need to set it directly, set var.quadPart.



~BenDilts( void );

Share this post


Link to post
Share on other sites
thanx for sugestion. however i did a stupid mistake i was outputing a float val using %d into char buffer. my mistake.

Share this post


Link to post
Share on other sites
thanx for sugestion. however i did a stupid mistake i was outputing a float val using %d into char buffer. my mistake.

Share this post


Link to post
Share on other sites

  • 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!