Obunako
07-14-2003, 10:18 AM
this is my FPS Counter code, but i'm not sure that is correct, what dou you think about ? something to repair ?
void FramesSecond(HWND h)
{
static float fps=0.0f,oldfps=0.0f;
* *static float lastTime=0.0f;
static char cad[30]={0};
* *float currentTime = GetTickCount() * 0.001f; * *
* *++fps;
if(currentTime-lastTime>1.0f)
*{
* * lastTime=currentTime;
*sprintf(cad,"Frames %.0f FPS",fps);
* * * *fps=0;
*}
SetWindowText (h,cad);
}
This function is called on WM_PAINT message...
case WM_PAINT:
*Render();
*FramesSecond(GetParent(hwnd));
*SwapBuffers(hdc);
*ValidateRect(hWnd,NULL);
*return 0;
And finally the paint event is called by an infinte loop into a thread...
DWORD WINAPI ThreadProcRepaint ( LPVOID lpParameter)
{
for(;;)
*{
*InvalidateRect((HWND) lpParameter, NULL, TRUE);
*UpdateWindow((HWND) lpParameter);
*}
}
thanks for all.
void FramesSecond(HWND h)
{
static float fps=0.0f,oldfps=0.0f;
* *static float lastTime=0.0f;
static char cad[30]={0};
* *float currentTime = GetTickCount() * 0.001f; * *
* *++fps;
if(currentTime-lastTime>1.0f)
*{
* * lastTime=currentTime;
*sprintf(cad,"Frames %.0f FPS",fps);
* * * *fps=0;
*}
SetWindowText (h,cad);
}
This function is called on WM_PAINT message...
case WM_PAINT:
*Render();
*FramesSecond(GetParent(hwnd));
*SwapBuffers(hdc);
*ValidateRect(hWnd,NULL);
*return 0;
And finally the paint event is called by an infinte loop into a thread...
DWORD WINAPI ThreadProcRepaint ( LPVOID lpParameter)
{
for(;;)
*{
*InvalidateRect((HWND) lpParameter, NULL, TRUE);
*UpdateWindow((HWND) lpParameter);
*}
}
thanks for all.