Original Post
🔒 Locked
A Timer Function.
Advertisement
DWORD m_FPSTimer;
DWORD m_FPS;
FILE* Stream;
stream = fopen("fps.txt", "a");
Draw()
{
m_FPS = ( 1000/( timeGetTime() - m_FPSTimer() ) );
m_FPSTimer = timeGetTime();
fprintf(stream,"%d",m_FPS);
}
///////////////////////////////////
//m_grinder - no brains, no clue.//
///////////////////////////////////
DWORD m_FPS;
FILE* Stream;
stream = fopen("fps.txt", "a");
Draw()
{
m_FPS = ( 1000/( timeGetTime() - m_FPSTimer() ) );
m_FPSTimer = timeGetTime();
fprintf(stream,"%d",m_FPS);
}
///////////////////////////////////
//m_grinder - no brains, no clue.//
///////////////////////////////////
I hereby give you my fps-class:
class Fps {
int framecount;
DWORD framestarttime;
int fps;
char buffer[50];
public:
Fps(void) : framecount(0) {}
void Start(void) { framestarttime=GetTickCount(); }
void Stop(void) {
fps=(int)(GetTickCount()-framestarttime);
fps=1000/(fps+1); //+1=security flag to make answer >=1, to avoid probable division by zero!
}
void Draw(void) {
sprintf(buffer,"Frames Per Second=%d",fps);
Draw_Text_GDI(buffer,0,SCREEN_HEIGHT-20,RGB(120,220,20),lpddsback);
}
};
Use it like this in your main-loop or whatever:
Fps framespersecond;
while(1)
{
framespersecond.Start();
Game_Main();
framespersecond.Stop();
}
In Game_Main() you can plot the fps like this:
framespersecond.Draw();
Note: I don''t assure you that this class is correct at all, it might be totally wrong.
If someone knows that this is wrong, please tell me.
/DDnewbie
Newbie
If you use winapi you can call GetTickCount. It is either in the kernel or user32. Try the following when using it.
StartTime = TickCount
Do_What_Ever
EndTime = TickCount
Time_It_Took = EndTime - StartTime
Check the DX samples. They have framerate code.
Sorry I can''t help you with finding the call. My computer just got a virus and I lost everything.
StartTime = TickCount
Do_What_Ever
EndTime = TickCount
Time_It_Took = EndTime - StartTime
Check the DX samples. They have framerate code.
Sorry I can''t help you with finding the call. My computer just got a virus and I lost everything.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement