Hey, I am trying to ensure that my application runs at a certain frame rate, but keep getting stuck in probably some infinite loop. Here is what I am doing in code, if someone could take a look...
// inside the while(1) loop
int currentTime = SDL_GetTicks();
int msBetween = currentTime - lastTime;
bool delay = false;
if(msBetween < (1000 / FPS))
{
delay = true;
}
if(delay)
{
SDL_Delay((1000 / FPS) - msBetween);
delay = false;
}
Trouble Capping Framerate
Moderator: PC Supremacists
- JarrodParkes
- ES Beta Backer
- Posts: 325
- Joined: Thu Feb 25, 2010 2:39 pm
- Current Project: Yes, iPhone Application(s)
- Favorite Gaming Platforms: N64, PC
- Programming Language of Choice: C++
- Location: Mountain View, CA
- Contact:
Trouble Capping Framerate
Jarrod Parkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes
- xiphirx
- Chaos Rift Junior
- Posts: 324
- Joined: Mon Mar 22, 2010 3:15 pm
- Current Project: ******** (Unkown for the time being)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Re: Trouble Capping Framerate
You never modify lastTimeJarrodParkes wrote:Hey, I am trying to ensure that my application runs at a certain frame rate, but keep getting stuck in probably some infinite loop. Here is what I am doing in code, if someone could take a look...
// inside the while(1) loop
int currentTime = SDL_GetTicks();
int msBetween = currentTime - lastTime;
bool delay = false;
if(msBetween < (1000 / FPS))
{
delay = true;
}
if(delay)
{
SDL_Delay((1000 / FPS) - msBetween);
delay = false;
}
StarCraft II Zerg Strategy, open to all levels of players!
Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of
Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of
- JarrodParkes
- ES Beta Backer
- Posts: 325
- Joined: Thu Feb 25, 2010 2:39 pm
- Current Project: Yes, iPhone Application(s)
- Favorite Gaming Platforms: N64, PC
- Programming Language of Choice: C++
- Location: Mountain View, CA
- Contact:
Re: Trouble Capping Framerate
thanks! i got it fixed now =)
Jarrod Parkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Trouble Capping Framerate
Nice, I must have missed this post. Did that fix the problem we were talking about the other day?
- JarrodParkes
- ES Beta Backer
- Posts: 325
- Joined: Thu Feb 25, 2010 2:39 pm
- Current Project: Yes, iPhone Application(s)
- Favorite Gaming Platforms: N64, PC
- Programming Language of Choice: C++
- Location: Mountain View, CA
- Contact:
Re: Trouble Capping Framerate
which problem? i think it so though
Jarrod Parkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes
Indie Game Development
Email: parkesfjarrod@gmail.com
Portfolio: http://jarrodparkes.com
Twitter: http://www.twitter.com/jarrodparkes
Facebook: http://www.facebook.com/jarrodparkes