[SDL] Surface Pitch inconsistencies?

Sam Lantinga slouken at devolution.com
Mon Aug 16 18:41:52 PDT 1999

> 	OK I'll admit this is probably a silly question and results from
> 	the fact that I really don't understand what pitch is completely
> 	but this is just confusing the heck out of me. I am writing a
> 	game that can run in both windowed and fullscreen mode at
> 	640x480x16. Now when I am in a window My Resolution is 640x480
> 	and my bytes per pixel is 2 making my pitch 1280 (which makes
> 	since since I thought that pitch was width of the screen in
> 	bytes which is 640 pixels times 2 bytes per pixel.) However,
> 	when I run in fullscreen mode at 640x480 My bytes per pixel is
> 	still 2 but my pitch seems to magically be 2560. (This makes
> 	absolutely no sense to me since I wouldn't expect the pitch to
> 	change. Shouldn't it still be 640*2? Why is it all of the sudden
> 	640*4?

The video memory is actually wider than the resolution you have requested.
To get to the next visible scanline, you need to skip over quite a bit.

	-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software
"Any sufficiently advanced bug is indistinguishable from a feature"
						 -- Rich Kulawiec 

More information about the SDL mailing list