This is my code, the result says 0.0f for fps and i am not sure why
BTW i know about
QuerryPerformaceCounter
GetTickCount
i just wanted to try to calculate the FPS with this function
Code:
MSG msg;
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//if(msg.message == WM_QUIT)
// break;
float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
render_frame(timeDelta);
lastTime = currTime;
if(KEY_DOWN(VK_ESCAPE))
PostMessage(hWnd, WM_DESTROY, 0, 0);
}
}
Code:
void CalcFPS(float timeDelta)
{
float FrameCount;
float FPS;
static float TimeElapsed;
char outBuffer[64];
FrameCount++;
TimeElapsed += timeDelta;
if (TimeElapsed>=1.0f)
{
FPS=(float)FrameCount/TimeElapsed;
TimeElapsed=0.0f;
FrameCount=0;
}
SetRect(&TextBox, 0, 80, 640, 480);
sprintf(outBuffer,"FPS = %f",FPS);
dxfont->DrawTextA(NULL,
outBuffer,
strlen(outBuffer),
&TextBox,
NULL,//DT_CENTER | DT_VCENTER,
D3DCOLOR_ARGB(255, 255,0, 0));
}