Advertisement Jump to content
Sign in to follow this  

making d3d object move by timeDelta fails

This topic is 2500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

for my game timer i am using TimeGetTime , i know there is other methods but i want to try this way for a chance, here is the code..., anyone could tell me how i could turn gDelta in to fps for TextingOut out to screen to that would be great.

before i enter the MSG loop

MSG msg;

static float lastTime = (float)timeGetTime();


if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
if (msg.message == WM_QUIT)



// check the 'escape' key
PostMessage(hWnd, WM_DESTROY, 0, 0);

float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f; //0.001f;
gDelta = timeDelta;

and when i go to render the d3d object

static float z = 0.0f;
D3DXMATRIX matRotateY,matTrans; // a matrix to store the rotation for each triangle
d3ddev->SetTransform(D3DTS_WORLD, &(matTrans)); // set the world transform

Share this post

Link to post
Share on other sites
Well, in your code z will always be 0 so the z component will always be 0.

Code for calculating FPS:

static float fFrameCount, fTimeElapsed;
fFrameCount++; // Increment the frame counter
fTimeElapsed += m_fTimeDelta = fTimeDelta; // Add the delta time to the elapsed time
// Calculate FPS
if(fTimeElapsed >= 1.0f) // More than or 1 second has elapsed
m_fFPS = fFrameCount / fTimeElapsed; // Set FPS
fTimeElapsed = fFrameCount = 0.0f;
// Format the FPS data to a string
::StringCbPrintf(m_szFPSData, ARRAY_SIZE(m_szFPSData, WCHAR), L"FPS: %.02f", m_fFPS);
m_oFPSDataString = m_szFPSData;
return m_fFPS; // Return the number of frames rendered per-second

Pass time delta parameter to this function...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!