[SDL] Weird surface behavior
adam at preston.net
Tue Aug 21 23:41:01 PDT 2001
Ti Leggett wrote:
> On 2001.08.22 00:56 Adam Gates wrote:
> > Ti Leggett wrote:
> > >
> > > if ( SDL_MUSTLOCK( surface ) )
> > > SDL_LockSurface( surface );
> > > Uint32 *surface_p = ( Uint32* )surface->pixels;
> > > if ( SDL_MUSTLOCK( color_map ) )
> > > SDL_UnlockSurface( color_map );
> > Shouldn't the Unlock be on 'surface'?
> So it should. Got mixed up, but it still has no effect.
> color_map->pixels should remain constant since all I do is load the image once
> and copy from it. surface->pixels should change only once (the first pass
> through). After that it should remain the same since color_map shouldn't
> > Also in the main loop don't you need to lock a surface even to get read
> > access to it (I am not sure)?
> >From what I've seen and what I've done before, no.
> > Your main loop also seems to assume the pixel size is always a UInt32.
> > You should have a look at the GetPixel/SetPixel functions in the doco.
> > http://sdldoc.csn.ul.ie/guidevideo.php
> I think (there I go again), that pixel info is always Uint32 it's just how
> it's stored in that 32 bits that's different (i.e., 24 bit surfaces ignore the
> first or last 8 bits depending on edianess). At least I assume so since both
> GetRGB and GetRGBA both return Uint32. Then again, I could be wrong and that
> could be my problem :)
You may be right on the other points, I'm not sure I'm just giving
ideas, but your last point about the pixel size is definately wrong.
GetRGB and GetRGBA both return Uint32 because all pixels will fit into
an Uint32 but in the pixel array the are packed according to the Bytes
Per Pixel (bpp) value.
More information about the SDL