[SDL] Blitting Speed/Surface formats

Joseph Humfrey joseph at mansefield.net
Sun Apr 6 16:02:01 PDT 2003


My game was going really slowly - around 28fps most of the time. I was 
doing very little:

	- clear the screen (blit a black rectangle onto the screen)
	- render 100 60x40 animated tiles on an 800x600 screen surface
	- render a few animated sprites
	- repeat

I guessed that it might have something to do with my loading functions 
(I wasn't really bothering to think about pixel formats/bitdepth). This 
is what I was doing to load spritemaps:

	- loadBMP the whole animation strip	
	- create a frame template/buffer surface of the size of one frame (no 
proper formatting at all)

	repeat for all frames {
	- convert the template to the format of the original strip, and put 
this new empty surface where I want my final loaded surface frame to be
	- blit a frame from the complete strip into where I want it to go
	}

So I saw this was wrong. I changed it to this:

	- loadBMP the whole animation strip
	- create a frame buffer with the format of the strip

	repeat for all frames {
		- blit a frame from the strip onto the buffer
		- convert buffer to format of screen as I put it where I want it
	}

That algorithm seems to make a lot more sense - but it doesn't work. 
SDL only seems to draw some of the frames, but not others! It 
definitely seems to be faster though. How should I be doing this?

Thanks,
--Joe





More information about the SDL mailing list