I have a question about choice of library to be used on low-end systems.
I've so far been using SDL to create a user interface for a media system, and it's been working fantastically on my development machine, a dual core 2GHz machine with 2Gb RAM and an Intel graphics card. I get a frame rate of up to 100fps, and there is no slowdown at all. However when I run the exact same program on an embedded motherboard, the VIA EPIA EN15000G, which has a 1.5GHz processor, and a VIA P4M800 graphics chip (possibly the worst graphics chip ever invented as far as Linux support goes), I get a frame rate of less than 5fps. This makes the entire program totally unusable, and I've been left in a bit of a pickle. I've looked into alternatives like SFML, but that looks like it won't help at all on an unaccelerated system. I've also tried using OpenChrome drivers on it, and that made a negligible or nonexistent difference.
Can anybody suggest anything I could look into re: optimising my code or changing libraries goes? I already use SDL_DisplayFormatAlpha to convert my surfaces to the correct format. I haven't looked into Dirty Rectangles yet massively, as there's not much movement at all on the GUI, just the changing of button states.
Would use of OpenGL help at all if using the OpenChrome driver, which apparently has 2D acceleration? I'm more than willing to totally overhaul the code if needs be.
Any help at all would be appreciated massively, as I'm a bit stumped, and floundering a little!
There is usually no single "use this instead of this to make everything 10 times faster" switch - if you want to optimize, start out with the obvious stuff - do you have unnecessary iterations in your loops that you could optimize out, do you have unnecessary variables, do you allocate unnecessarily large chunks of memory etc...
Haha, yeah I'd have guessed that it wasn't likely that it'd be one thing that I was doing which caused it. To be honest, I'm fairly new to C++ and generally low level programming.
I do quite a lot of iteration through arrays of SDL_Surfaces to work out what needs to be updated on the screen and then updating it. I'll look into possibly changing my thinking on how I deal with that.
I'll take those points and make good use of them to start with :-) Thanks, mate!
Surely, this should be running at an insanely fast speed, given that it's not doing ANYTHING. It also looks like I screwed up my frame speed in my first post. the 100 was ms/frame, not FPS. The FPS is anything between 6 and 40.
Anybody have any ideas why this is producing such an incredibly low frame rate? I've heard of people getting frame rates in the hundreds, if not thousands with far lower spec machines than mine. It's a little worrying.
That code is there to limit the FPS to a variable FRAMES_PER_SECOND. Sorry, should have posted that too. I've set it to 150, to find the maximum I could manage. SDL_Delay does halt the execution, but only if the frame processes faster than 1000ms/FRAMES_PER_SECOND, which in this case would be 6. The loop takes more than that to process, so the conditional will never be triggered.
I've tested this theory with the Code::Blocks default SDL project, and done nothing but print the frames per second at the end of the loop. I got very similar FPS as I did in my own project (maybe 5-10fps difference). This is leading me to believe that SDL is actually horribly slow, and my code is fine. I'll post the code for this at the end to show how non-processor-intensive this should be.
Any ideas, anybody? I'm starting to lose faith in how awesome SDL seemed :-(