Archived

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

RyuuKurai

Simple Question, I hope

Recommended Posts

I started learning OGL a while ago, then gave up, and now am starting again. Well, I decided to make a simple little screensaver using the VB conversion of NeHe''s basecode. The problem is, it''s so simple that it runs way too fast. I was just wondering if anyone knew how I could implement a frame rate limiter. Any help would be appreciated. And also, I would like to express my condolences to Jeff and his family. Losing a family member is never easy, and he is a very strong man for being able to still keep the site updated. My most heartfelt condolences to him.

Share this post


Link to post
Share on other sites
You don''t need to limit your frame rate.
What you need to do is measure the time between two frames (there is a timer somewhere on the site) and use that as your timestep (i.e. instead of doing pos += velocity, you do sth like pos += timestep * velocity ).

Share this post


Link to post
Share on other sites
I thought about doing that, but the way the program runs it wouldn;t work right. The program is a double-helix that grows and shrinks, as well as rotates around the x and y axis. I add one step (or remove one, depending on whether it is currently growing or shrinking) every frame. Maybe I could just have it add a step everytime the timer reaches a certain value? Would you happen to know what/where I could find the VB syntax for the timer? (the timer control doesn''t work, unfortunately)

Share this post


Link to post
Share on other sites
hmm.. ok, then try this : measure the time rendering a frame takes, and then sleep() for the ''remaining'' amount of time that will bring your framerate down to the desired value.

Or have your update function just return without doing anything if the right amount of time hasn''t elapsed yet.

Share this post


Link to post
Share on other sites
When you do something like this:

pos += velcocity * deltaTime;

You can interpret it as move the object''s position x units per second. So in other words, velocity should equal the distance you want the object to move per second. If you think about the math for a second or two, you''ll realize this works.

Share this post


Link to post
Share on other sites
Thanks Fruny! I can''t believe I didn''t think of that. He he.

And Floppy, I know how it works. But it''s not just moving, the object itself is increasing in steps, so it can''t increase by a fractional value.

Share this post


Link to post
Share on other sites