Sign in to follow this  
BennettSteele

C++ (openGL + openAL) game loop DT

Recommended Posts

So i am using C++, openGL and openAL, and have a main loop, like:

[code]
while(!done)
{
int oldTime=APP.Timer;
APP.Timer=timeGetTime()-APP.StartTime;
float DT=APP.Timer-oldTime;
std::stringstream Loler;Loler<<DT/100;

GameLogic(DT/100);
}


[/code]


and i need it to run as fast as it would on any computer, like taking that delay of frames to calculate how to increment all the values.

Share this post


Link to post
Share on other sites
[quote name='bennettbugs' timestamp='1318476786' post='4872069']
So i am using C++, openGL and openAL, and have a main loop, like:

[code]
while(!done)
{
int oldTime=APP.Timer;
APP.Timer=timeGetTime()-APP.StartTime;
float DT=APP.Timer-oldTime;
std::stringstream Loler;Loler<<DT/100;

GameLogic(DT/100);
}


[/code]


and i need it to run as fast as it would on any computer, like taking that delay of frames to calculate how to increment all the values.
[/quote]

Hmm, have you looked at this article: [url="http://gafferongames.com/game-physics/fix-your-timestep/"]http://gafferongames...-your-timestep/[/url] it talks about having a fixed timestep for physics with visual interpolation based on DT, but I've also used a variant of tha loop to do both physics and gamelogic.

Share this post


Link to post
Share on other sites
What's your actual question? You've already calculated dt, so now all you need to do is plug that in as your time value in your simulation tick.

Maybe if you show your code for the simulation/rendering ticks we could point out what needs to be adjusted?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this