[SDL] Weird surface behavior

Ti Leggett leggett at eecs.tulane.edu
Tue Aug 21 23:17:01 PDT 2001


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
change.

> 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 :)


-- 
Ti Leggett
leggett at eecs.tulane.edu




More information about the SDL mailing list