[SDL] Weird surface behavior

Johann Deneux johannd at DoCS.UU.SE
Wed Aug 22 07:10:01 PDT 2001


On Wed, 22 Aug 2001, Ti Leggett wrote:

>[...]
>                     Uint32 *color_p = ( Uint32* )color_map->pixels;
> 
>                     for ( int i = 0; i < 320; i++ )
>                         {
>                             unsigned int pos = j * 320 + i;
>                             printf( "Before s: %u c: %u", surface_p[pos],
> color_p[pos] );

Are you sure there is data at color_p[pos] ? If the size of a pixel stored
surface->pixels is smaller than 32 bits, this instruction is not valid.

>                             Uint32 pixel = getpixel( color_map, i, j );
>                             putpixel( surface, i, j, pixel );
>                             printf( " After s: %u c: %u i: %d j: %d\n",
> surface_p[pos], color_p[pos], i, j );

Same remark as above.

>[...] 
> 
> And it still segfaults at that magic row 150.

If you remove your printf, it may work.

-- 
Johann Deneux
http://www.esil.univ-mrs.fr/~jdeneux/projects/






More information about the SDL mailing list