[SDL] Better performance needed - am I doing this right?
Eddy L O Jansson
eddy at klopper.net
Wed Jun 6 11:25:43 PDT 2007
On Wed, 06 Jun 2007 19:49:02 +0200, Colin Tuckley <colin at tuckley.org> wrote:
>> Maybe you should use a dirty-rectangle approach
>
> As I said to Rúben, I've tried that.
Even so, I'd be chocked if this wasn't an update issue. Do you have just the one SDL_Flip in your code? Whatever the case, its placement is odd and probably bad design, unless merely temporary for debugging. It's not clear to me that what you actually measured when you say it didn't make a difference. (Sorry to be a doubter, but this "SDL is slow" thing has come up a "few" times here in the past)
> You suggested timing things, How? I'm begining to suspect that it's all the
> pixel manipulation thats taking the time.
You can use Uint32 SDL_GetTicks(void) to track the relative time spent doing different tasks. Collect and compare the ticks spent doing pixel manipulations vs the time spent with SDL_Flip would be my first idea.
> Do you have an example somewhere of doing that which I could look at?
No really, but it's fairly straight forward: Prepare a surface with room for all your glyphs, get them on there, and then use just a SDL_Rect to slide to the correct y-position and blit to your destination surface.
One thing, if you are going to fiddle with ->pixels, don't forget to add if( SDL_MUSTLOCK(surface) ) SDL_LockSurface(surface) and the corresponding SDL_UnlockSurface() when you're done.
More information about the SDL
mailing list