Re: [AD] DirectX Windowed mode, one more try

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Dominique Biesmans <d_biesmans@xxxxxxxxxx> writes:
> I think the biggest problem is that DX doesn't support hardware blits
> between surfaces with different palettes (well maybe it does, but I don't
> think it will do conversions between the palettes).

Does it support blitting between different surface color depths? If so that 
might be a good way to handle windowed modes where Allegro has a different 
color depth to the Windows desktop: rather than trying to reuse the X 
conversion code, we could just let DirectDraw take care of this during the 
blit.

> The problem is the 10 first & 10 last colors of the palette. We could 
> create a lookup table that would map those 20 colors from the original 
> palette to the resulting palette (which is the same as the original 
> except for those 20 colors). The backbuffer would then be blitted to the 
> desktop surface using a specific software blitter that uses our (small) 
> lookup table for pixels using those 20 colors. This won't always look 
> good, but it will look as good as possible.

That sounds like the right approach to me. It keeps the palette fixup code 
entirely in one small place (the copy from backbuffer to screen), so the 
rest of Allegro doesn't need to care about this, and user programs will 
never be confused when the palette needs to be remapped (eg. they can 
putpixel() to the backbuffer, then getpixel() to read it back, and always 
get exactly the results they expect even if that particular color isn't 
actually in the current Windows palette). Also, this mapping from internal 
Allegro palette to Windows desktop palette happens in exactly the same 
place as converting if the Allegro surface is in a different color depth 
to the Windows desktop, so it is really just a subset of that larger 
problem. The fast case is where the Allegro backbuffer is in the same 
format as the real screen, so a hardware blit is possible, but if the 
color depths differ, or a paletted mode is in use, we can just do color 
conversion during the blit instead.

It will always look a bit strange when some of the palette entries go 
missing, and palette fades are always going to have strange side effects, 
but that's the nature of being in a windowed environment. Multiple 
programs in different windows just don't mix with the idea of a global 
hardware palette, unless you do the standard Windows UI thing and never 
even try to change the palette at all :-)


--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/