Jump to content
  • Advertisement
Sign in to follow this  
POLSKASH

mmsystem.h

This topic is 4725 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

I'm using the timeGetTime() function, and I'm getting this error: error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function _WinMain@16 Debug/Testing Ground.exe : fatal error LNK1120: 1 unresolved externals Am I forgetting something?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by POLSKASH
Am I forgetting something?


Probably forget to link with the static lib winmm.lib (windows multi-media library).

Share this post


Link to post
Share on other sites
My particle engine's update function needs the elapsed time since it was last called. Here is what my main loop looks like:

while(Msg.message != WM_QUIT && isPlaying)
{
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else
{
if(time_now - movement_timer > CLK_TCK/40) //For locking FPS, not being used ATM
{
movement_timer = time_now;
}

if(currentTime == 0) //If this is the first time currentTime is being called
{
currentTime = timeGetTime();
lastTime = currentTime;
currentTime = timeGetTime();
}
else //Otherwise just call for the current time
{
currentTime = timeGetTime();
}
elapsedTime = (float)((currentTime - lastTime) * 0.001); //Get elapsed seconds
lastTime = currentTime;

D3D_device->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_RGBA(0,0,0,0),1.0f,0);
D3D_device->BeginScene();

sparks->UpdateSystem(elapsedTime); //Send in elapsed number of seconds
sparks->RenderSystem();


D3D_device->EndScene();
D3D_device->Present(NULL,NULL,NULL,NULL);
}
}



I think I need a better method for calculating the elapsed time. Does someone have a better method they use? This is one isn't working right.

Share this post


Link to post
Share on other sites
the problem is that you're subtracting lastTime witch is already scaled to seconds .

try to change

elapsedTime = (float)((currentTime - lastTime) * 0.001);
lastTime = currentTime;

into

elapsedTime = ((float)currentTime * 0.001) - lastTime;
lastTime = currentTime;

Share this post


Link to post
Share on other sites
Quote:
Original post by kusma
the problem is that you're subtracting lastTime witch is already scaled to seconds.


I don't think so. lastTime is set to currentTime. currentTime is set to timeGetTime().

Where is lastTime getting scaled?

Share this post


Link to post
Share on other sites
Quote:
Original post by POLSKASH
My particle engine's update function needs the elapsed time since it was last called. Here is what my main loop looks like:
*** Source Snippet Removed ***

I think I need a better method for calculating the elapsed time. Does someone have a better method they use? This is one isn't working right.


When you say "isn't working right," what exactly do you mean? Remember that timeGetTime() isn't particularly precise. It may be that, due to lack of precision, you are getting zero elapsed time frequently. You should probably look at QueryPerformanceCounter(). That is a much more precise timer.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!