Re: [AD] trying to make allegro compatible with MFC

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


On Wed, Aug 01, 2001 at 01:00:03AM +0200, Javier González wrote:
> the platform SDK docs say
> 
> COLORREF RGB(
>   BYTE bRed,    // red component of color
>   BYTE bGreen,  // green component of color
>   BYTE bBlue    // blue component of color
> );
> 
> #define RGB(r,g,b)
> ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))

That's two different things then -- a function called RGB
returning a COLORREF, and a macro, presumably because that's
faster than the function -- sort of like inlining it.  If this
is the case then we can easily wrap the RGB function in a file
which is just this:

    #include <windows.h>
    COLORREF MFC_RGB (BYTE bRed, BYTE bGreen, BYTE bBlue)
    {
        return RGB(bRed, bGreen, bBlue);
    }

Then add a prototype for MFC_RGB to winalleg.h:

    COLORREF MFC_RGB (BYTE bRed, BYTE bGreen, BYTE bBlue);

and go on doing "#undef RGB" after including windows.h.  If the
user wants Allegro's RGB struct they use RGB; if they want MFC's
function then they use MFC_RGB.  The only thing not available is
the `inlined' (#defined) version of RGB.  Is speed critical?

George



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