static DWORD millisecs;
static char buffer[20];
static float fps;
millisecs = GetTickCount();
/* clear back buffer */
/* get keyboard input */
/* blit one block around according to key input */
if(GetTickCount() == millisecs)
sprintf(buffer, "FPS: MAX");
else {
fps = 1.0f / (((float)GetTickCount() - (float)millisecs) / 1000.0f);
sprintf(buffer, "FPS: %f", fps);
}
/* get DC and write fps using TextOUT */
This has been giving me "FPS: MAX" every single time. Shouldn't a memory fill, some keyboard checks, and a blit take at least one millisecond?
Please give a newbie some help
Four WARRIORS arrive, each holding an ORB...
Edited by - UberXenon on 6/10/00 11:12:16 PM
Question about timing
I started my first game a few days ago. It's a simple Tetris clone. I was just trying to get an accurate FPS readout so I could see how fast things were running. My question is, is GetTickCount() sufficient for this, or do I need to use QueryPerformanceFrequency() and QueryPerformanceCounter() to figure my FPS? I have a feeling that GetTickCount() isn't accurate enough. The following code is how my main game loop goes...
------------------------------------------------------------Four young warriors arrive, each holding an ORB...byrdjb@email.uah.edu
Ooops, I forgot to close my code tag, but you get the idea
------------------------------------------------------------Four young warriors arrive, each holding an ORB...byrdjb@email.uah.edu
I think GetTickCount() should suffice. Keyboard checks, a memory fill and a blit may take less than 1 second if you have a killer system.
========================================================
If something sounds stupid but works, it's not stupid
========================================================
If something sounds stupid but works, it's not stupid
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
is there only one "=" in
if(GetTickCount() = millisecs)
I think that would cause the problem because it would always be true(non-zero) (unless millisecs is zero which I doubt)
Dethsled
if(GetTickCount() = millisecs)
I think that would cause the problem because it would always be true(non-zero) (unless millisecs is zero which I doubt)
Dethsled
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement