On Sat, 09 Aug 2008 08:26:59 -0700, David O'Toole <[EMAIL PROTECTED]> wrote:

> It would be good to have a somewhat fuller explanation of what surface
> and channel alpha actually mean and how they compare, and a few use
> cases for common things that people want to do (like composing
> transparent PNGs). Right now it appears to be explained more or less
> directly in terms of the underlying C API symbols and not in terms of
> results (i.e. what you will see.)

The way SDL handles surfaces is confusing which is half of the problem.  
Having lispbuilder-sdl just do the right thing is the other half of the  
problem, and is becoming quite tricky as I try to handle edge cases.

The SDL_CreateSurface function in SDL will make the decision to place a  
surface in Video memory or System memory at time of surface creation,  
taking into account the specified suface flags SDL_SWSURFACE,  
SDL_HWSURFACE, SDL_SRCCOLORKEY, or SDL_SRCALPHA. If you request that a  
SDL_Surface is created in Video memory using SDL_HWSURFACE+SDL_SRCALPHA,  
SDL will return a SDL_Surface in System Memory if your hardware does not  
support hardware-accelerated alpha-blending blits. Having this type of  
surface in System memory is more efficient.

Trouble is, if you create a surface in Video memory using SDL_HWSURFACE  
and then set SDL_SRCALPHA using SDL_SetAlpha, the surface will remain in  
Video Memory. SDL won't automatically move your suface from Video to  
System memory. Now using the surface is very inefficient.

Another example, when creating an RGBA surface, SDL will automatically set  
the SDL_SRCALPHA flag, and thus perhaps forcing the surface into System  
memory instead of the programmer requested Video Memory. Using  
SDL_SetAlpha will remove the SDL_SRCALPHA flag, but this won't move the  
SDL_Surface back into Video memory.

Perhaps just making this kind of behaviour explicit in the lispbuilder-sdl  
documentation is sufficient.

- Luke
_______________________________________________
application-builder mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to