My program freezes completely. I think this is due to the Operating system not having enough time to update essential programs that are always running. |
That's not what's happening. If your program isn't getting CPU time, doing a Delay wouldn't help anyway because your program would not be running so the OS doesn't know it wants to delay. But you are getting CPU time. Check task manager and look at it. If you aren't doing any delays you will be using 100% (or close to it).
If your program is truly freezing (as in deadlock), then you're either caught in an infinite loop (extremely likely) or you are botching a multithreaded task and two or more threads are stuck waiting for each other.
If it's the former, it's very easy to debug. Just reproduce the deadlock, then go in your debugger and force it to break. It'll put you on the currently executing line, then just look for whatever loop that code is running in to see why it's deadlocking.
Well, this time the problem between us is CPU usage. |
In my experience, SDL's performance sucks. It's the main reason I stopped using it. I had trouble maintaining 60 FPS on a tiny 320x240 display on my old 1 GHz machine (this was maybe 8-9 years ago I think... 1 GHz wasn't top of the line but it wasn't garbage yet).
I find that SDL tends to do it's rendering in software, which is painful. It might do it that way because the drawing methods it uses are so archaic and outdated (blitting? dirty rects? This isn't 1996 any more). But that's purely speculation on my part.
I need a more "Heavey Duty" version of frame rate control than before. |
I have an excellent framerate regulator that does a great job at keeping the framerate steady. I wrote it for my NES emulator a while back.
You can find it here:
http://forums.nesdev.com/viewtopic.php?p=57398#p57398
(please forgive my use of Hungarian Notation. I was young).
I'm happy to answer questions about it, but that post should explain it pretty well.
(EDIT: corrected link. I gave the link to the Sound Sync version, not the clock version)