Jump to content
  • Advertisement
Sign in to follow this  
Anddos

making d3d object move by timeDelta fails

This topic is 2344 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();

while(TRUE)
{


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

TranslateMessage(&msg);
DispatchMessage(&msg);
}

render_frame();

// check the 'escape' key
if(KEY_DOWN(VK_ESCAPE))
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
D3DXMatrixTranslation(&matTrans,0.0f,0.0f,z*gDelta*1.0f);
d3ddev->SetTransform(D3DTS_WORLD, &(matTrans)); // set the world transform

Share this post


Link to post
Share on other sites
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!