Partial transparences in DriectDraw

Started by
3 comments, last by Nullio 22 years, 5 months ago
Is there a fast way of doing this?? I guess I could gou (Pixel bottom + pixel top) * % of tranparences. But there has to be a faster way
Advertisement
Assuming you still mean locking a surface and twiddling with every pixel (as opposed to faster methods like using 3D hardware):

For quick 50/50 transparency:

1. Build a mask from the colour masks in the pixel format.
dwMask = dwRedMask & (dwRedMask << 1);
dwMask |= dwGreenMask & (dwGreenMask << 1);
dwMask |= dwBlueMask & (dwBlueMask << 1);

2. Do the blend:
dest = ( (source & dwMask) + (dest & dwMask) ) >> 1;

You can modify the mask and shifting for other transparencies and effects.


IIRC there is also coverage of some other methods such as fragment lookup tables in the DirectX FAQ:
http://msdn.microsoft.com/library/techart/DirectX8faq.htm



--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

http://www.gamedev.net/reference/articles/article817.asp is the fastest way I know of to do it. It''s designed for 16-bit color, but you could probably convert it to use 32 bit if needed. The whole way it speeds things up is by processing 4 pixels at a time though, so doing 2 at a time in 32 bit wouldn''t give you a huge speed boost.


-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)
Ok, say I wanted to do it useing 3d accel, what can I do (using Direct Draw)
quote:Original post by Nullio
Ok, say I wanted to do it useing 3d accel, what can I do (using Direct Draw)


If you want hardware 3D accel you have to use D3D
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi

This topic is closed to new replies.

Advertisement