[SDL] Surface Pitch inconsistencies?

Warren Downs warren at businesslink.com
Mon Aug 16 19:14:32 PDT 1999

     Oh, BTW, X makes use of this feature of video cards: try setting a 
     larger virtual desktop than your video resolution, and you'll have 
     high speed panning of the display of the larger resolution you 
     specified (assuming you have enough video ram for this).
______________________________ Reply Separator _________________________________
Subject: Re: [SDL] Surface Pitch inconsistencies?  
Author:  <sdl at surfnetcity.com.au > at internet-mail
Date:    8/16/99 5:53 PM

     Well, I may be wrong, but my guess is, pitch is referring to the video 
     RAM allocated to a scanline by your video card.  So when running full 
     screen, the video card has enough ram you could be running at 
     1280x1024, so it allocates that much for each line.  This way, the 
     address of each line doesn't change even when the resolution does, 
     which makes for more efficient card design.  Also, you can easily do a 
     side scroller this way, by changing the starting address of the screen 
     in the video buffer (though only if you're programming the card 
     directly, say, in DOS).
     However, when running windowed, a larger pitch than the bytes per used 
     by your window per scanline can't be used by you anyway, as you don't 
     have permission to write outside your window, so SDL sets the pitch to 
     the width of the window in pixels * number of bytes per pixel.
______________________________ Reply Separator _________________________________
Subject: [SDL] Surface Pitch inconsistencies? 
Author:  <sdl at surfnetcity.com.au > at internet-mail 
Date:    8/16/99 5:39 PM
        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?

More information about the SDL mailing list