Wednesday, December 26, 2007

This one has been actually gleaned through a usenet post, but needs a wider coverage

Trying to use dwAlphaConst member of DDOVERLAYFX structure to specify overall overlay transparency results in E_INVALIDARG error

As explained here, there is a clever bug in the parameter checking logic that results in the API soundly rejecting any combination of dwAlphaConst and dwAlphaConstBitDepth, unless dwAlphaConst == 1 << dwAlphaConstBitDepth. This is not fixed as of WM 6 AKU4. Interestingly enough the actual value of dwAlphaConstBitDepth seems to be ... ignored, once the parameter check is done. The bit depth used is always 8 bit.

  • The net result of this bug is that the allowed values for the dwAlphaConstBitDepth/dwAlphaConst and the resulting opacity are
    1/2 - 0.78%
    2/4 - 1.6%
    3/8 - 3.1%
    4/16 - 6.2%
    5/32 - 12.5%
    6/64 - 25%
    7/128 - 50%

Not using DDOVER_ALPHACONSTOVERRIDE gives you of course 100% (opaque overlay). In my experience anything under 5 (12.5%) is too small to be useful, but YMMV. Here is the code snippet:

if ( fUseAlpha )
{
    if ( dwAlpha > 8 ) // Bug in ddraw
        dwAlpha = 8;
    if ( dwAlpha < 8 )
    {
        dwUpdateFlags |= DDOVER_ALPHACONSTOVERRIDE;
        ovfx.dwAlphaConst = 1 << dwAlpha;
        ovfx.dwAlphaConstBitDepth = dwAlpha;
    }
}

12/26/2007 1:50:12 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]  | 
3/23/2008 12:24:58 AM (Pacific Daylight Time, UTC-07:00)
Cool, the post.

Thanks for the information.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):