Hmmmm. It's working as it should, but not as I want it too. So, it's not technically broken. :D
Anyway, I'm putting it aside for now to re-visit it tomorrow.
Time based rendering placement problems (updated)
It's been a while, but here I am again.
I've made some modifications which absolutely did not work, so I scrapped it all.
Here's what I've got:
This was supplied by hplus0603 earlier in the thread. But, with this code, the fps starts at 10, and just halves every couple of seconds. So, I thought that I'd post it here in case anyone can give me a hand while I'm figuring it out.
Also, a question: does it matter whether vsync is on or not if the application is not being run fullscreen? Because I'm don't even have support for fullscreen at the moment, I'm just running it windowed.
[Edited by - Endar on May 23, 2006 4:21:45 AM]
I've made some modifications which absolutely did not work, so I scrapped it all.
Here's what I've got:
while( engine->run() ){ toSleep = nextTime - hiResTimer.getElapsedSeconds(); // set the time to sleep sleepTime = (int) (toSleep * 1000); Sleep( sleepTime ); // turn the float into milliseconds nextTime = hiResTimer.getElapsedSeconds() + desiredFrameTime; /* render the scene (no physics yet) */}
This was supplied by hplus0603 earlier in the thread. But, with this code, the fps starts at 10, and just halves every couple of seconds. So, I thought that I'd post it here in case anyone can give me a hand while I'm figuring it out.
Also, a question: does it matter whether vsync is on or not if the application is not being run fullscreen? Because I'm don't even have support for fullscreen at the moment, I'm just running it windowed.
[Edited by - Endar on May 23, 2006 4:21:45 AM]
I had put this aside for a while, but I'm attempting to make it work again, and I'll probably need help.
I made actually a class for this purpose. I call it the "sequencer". Every object in the program uses it to update itself at certain interval. When I say object, it includes sound systems, environmental controlling, physics, internal clocks plus of course the objects in the gaming environment (characters, vehicles). To solve certain dependancies there are several sequencers, (working possibly at different frame rates).
So, the none of the top level loops have any timing code in them. This sequencer is used with a certain event object. The event object calls a call back within the objects at a requested frame rate. Plus, for interpolation purposes, this event object can be request for alpha value between the frames.
With this system, the main loop becomes quite clean:
while(having_fun)
{
Sequencer->Poll();
Render();
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement