Inside of you main loop you call Render() and pass the frame time delta for that frame.
Code:
//
// WinMain
//
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
//Create window for app
if(!g_ZeldaApp.InitD3D(hInstance,
WIDTH,
HEIGHT,
false,
D3DDEVTYPE_HAL,
&g_pDevice))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
if(!Setup())
{
::MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
g_ZeldaApp.EnterMsgLoop(Display);
//We are done so clean up the memory and COM objects
Cleanup();
//Give our device back to COM
g_pDevice->Release();
return 0;
}
Code:
int CD3DApp::EnterMsgLoop(bool (*DisplayFunc)(float timeDelta))
{
MSG msg;
::ZeroMemory(&msg, sizeof(MSG));
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT)
{
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
DisplayFunc(timeDelta);
lastTime = currTime;
}
}
return msg.wParam;
}
That's how I've set mine up. There are other ways to do it.
Display is a function pointer that points to Render().