Advertisement Jump to content
Sign in to follow this  


This topic is 3837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I just got SDL_gfx, but there's a problem. I don't know how to use the built-in framerate regulator (SDL_Framerate.h). It's completely undocumented from what I can see, so I don't know what functions to call within my code to use it. Can anybody tell me how to use it? Thanks in advance, ukdeveloper.

Share this post

Link to post
Share on other sites
It's actually fairly easy.

First thing you need to do is create an FPSmanager (the structure can be found in SDL_framerate.h).

So then call SDL_initFramerate(), before your main game loop. Pass your FPS manager dealy-o to it so it can set up all the values for your new manager.

You can then set the target framerate using the SDL_setFramerate method. The default is 30, so you dont really have to worry about this if you dont want to.

Anyway, during the game loop, or more specifically at the end or beginning of the loop, call SDL_framerateDelay(). This will loop until your framerate is met, or just do nothing if you are running under 30 fps.

So here is an example..

// start program

FPSmanager * manex;

SDL_initFramerate( manex );
// you want the top framerate to be 60 for example
SDL_setFramerate( manex, 60 );
while (loop)
// process your graphics, ai, sound, etc here

SDL_framerateDelay( manex );

That is very basic, and I dont reccomend using the SDL_framerate stuff. It delays processing, which is never good. Used motion based framerate caps...the way above wastes CPU time.

I hope that helped..i've never actually used it, i just looked at the .c and .h file.

Share this post

Link to post
Share on other sites
Hiya :)

Found this post on Google while looking for the SDL_gfx framerate manager, and its perfect for what i was after, except I'm intrigued by c-gibson-s's comment on a motion based framerate cap, can anyone elaborate on that?


Share this post

Link to post
Share on other sites
HERE A post I made in this very board, a couple down from your post. I've found it very helpful... not to say I think I've cracked it yet.
There are some articles on this site too and the web is full of them from what I've found. Seems it isn't as simple than it is at first look.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!