[SDL] "explosions" demo

William Kendrick nbs at sonic.net
Wed Aug 1 17:51:00 PDT 2001


On Wed, Aug 01, 2001 at 11:53:32AM +0000, Samuel Hart wrote:
> On Tuesday 31 July 2001 11:30pm, William Kendrick wrote:
> > Best of all, I've totally commented the code (more so than usual :) )
> > so some of you might find it useful, even! ;)
> >
> >
> >   ftp://ftp.sonic.net/pub/users/nbs/unix/x/explosions/
> 
> This is actually very kewl. ;-)

Thanks!  I have a question about SDL, though...

Can someone give me a REAL simple, portable example piece of code to
read pixels (into RGB) and write pixels (as RGB) to and from a surface?

Everything I've tried either seems to push out two pixels at a time
(I'm using 16bit depth surface on a 16bbp X server) or segfault. ;)


My current _lame_ way of doing it is reading pixels off the surface
using SDL_BlitSurface() (with a 1x1 rectangle... once for each pixel.. UGH!)
and then grabbing their RGB value by examining the "surface->pixels" RAM
in the surface I just blitted into (ie, to get the (0,0) position pixel)


To write into the surface (after altering the RGBs I just read), I use
SDL_FillRect() (with a 1x1 rectangle... once for each pixel... DOUBLE-UGH!)


Anyone got something simple you can show me?  Esp. with lots of comments
(since I'm sure in involves pointer hell :( )


Thanks!

-bill!
(working on frame bluring :) )




More information about the SDL mailing list