[SDL] 'Cutting a Hole' in a Surface

Leeor leeor_net at yahoo.com
Tue Nov 27 10:30:44 PST 2007


The name should say it all but I will explain what it is that I'm trying to do.

I am trying to create the illusion of a point light on a flat surface. I'm sure 
I could do this somehow with OpenGL but, frankly, I hate OpenGL and I want to 
stick with 2D hardware as it is.

The way I had thought to do this is to create a 'darkening mask' by filling a 
Surface with a color, let's say Black ( rgb=000) to the same size as my primary 
video surface. This would then be blitted on top of everything making the 
screen appear black. (This illusion, of course, could be made even better by 
working with Alpha's but let's ignore that for now).

Then, the create the illusion of a point light, I would cut a 'hole' in the 
surface so that when blitted, there's the appearance of a square 'hole' (e.g., 
the light).

I've tried a few things that don't seem to be working as well as I would have 
liked. Any suggestion on how I can 'cut a hole' in a surface?

Also, I've thought of just using a few Rect's or a Rect list to kind of draw 
around the 'hole' but I don't see this as being too feasible in a real-time 
sense with the light source bouncing around.



More information about the SDL mailing list