Archived

This topic is now archived and is closed to further replies.

DrKiRR

PortaLib world update callback et al.

Recommended Posts

Hi there! this is a question to everyone, but i'd really appreciate Brett's answer (caus he is father of PL3D, after all . Here it is: if I, say, would want to write a demo, where my camera would rotate around a group of objects, i, obviously would need to update camera position from time to time and render the world according to the new position. Okay, i can do it in the drawScene function, but here's the trouble - if your PC can do 70 FPS your camera would rotate fast, if your PC is slow and does only 15 FPS, your camera would move quite slowly. Obviously, we need a way to have our updateWorld (or something like this) function to be called at a certain rate. At present time we have only one user-definable callback (drawScene). So, how do we solve it? Is it going to be solved in the upcoming (and looked forward to, at least by me) PL3D v0.2.0 ? Any suggestions ? Thanx. Dr. KiRR -------- Dr. KiRR's stuff is at http://www.geocities.com/drkirr Edited by - DrKiRR on June 12, 2001 5:32:48 AM

Share this post


Link to post
Share on other sites
Been a bit slow on the new release - many apologies
A lot to do and so little time.

I think what you want is a timer...

Timer *pTimer = Timer::getNewTimer();
in your constructor
int lastUpdate = 0;

drawScene()
{
long time = pTimer->getTime();
if ( time - lastUpdate > 1000 )
{
update();
lastUpdate = time;
}
}

Updates once a second.

HTH!

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL

Share this post


Link to post
Share on other sites
Yes, that''s something like i had in mind...
Actually, i asked cause i thought someone could come up
with something better (it''s not that this system is bad,
i just see several potential problems here).
BTW, by the time you answered, i have already implemented
something like it (sorry, Brett, i should have said that before) - i''m currently working on a simple mm.. "demo"
called "Day & Night".
Soon to be released...

Share this post


Link to post
Share on other sites