Archived

This topic is now archived and is closed to further replies.

Nullio

Partial transparences in DriectDraw

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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^_^)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites