Exemple #1
0
bool SetBlender(BlendMode blend_mode, bool dst_has_alpha, bool src_has_alpha, int blend_alpha)
{
    if (blend_mode < 0 || blend_mode > kNumBlendModes)
        return false;
    const BlendModeSetter &set = BlendModeSets[blend_mode];
    PfnBlenderCb blender;
    if (dst_has_alpha)
        blender = src_has_alpha ? set.AllAlpha :
            (blend_alpha == 0xFF ? set.OpaqueToAlphaNoTrans : set.OpaqueToAlpha);
    else
        blender = src_has_alpha ? set.AlphaToOpaque : set.AllOpaque;

    if (blender)
    {
        set_blender_mode(nullptr, nullptr, blender, 0, 0, 0, blend_alpha);
        return true;
    }
    return false;
}
Exemple #2
0
void ALSoftwareGraphicsDriver::RenderToBackBuffer()
{
    for (int i = 0; i < numToDraw; i++)
    {
        if (drawlist[i] == NULL)
        {
            if (_nullSpriteCallback)
                _nullSpriteCallback(drawx[i], drawy[i]);
            else
                throw Ali3DException("Unhandled attempt to draw null sprite");

            continue;
        }

        ALSoftwareBitmap* bitmap = drawlist[i];
        int drawAtX = drawx[i];// + x;
        int drawAtY = drawy[i];// + y;

        if ((bitmap->_opaque) && (bitmap->_bmp == virtualScreen))
        { }
        else if (bitmap->_opaque)
        {
            blit(bitmap->_bmp, virtualScreen, 0, 0, drawAtX, drawAtY, bitmap->_bmp->w, bitmap->_bmp->h);
        }
        else if (bitmap->_transparency >= 255)
        {
            // fully transparent... invisible, do nothing
        }
        else if (bitmap->_hasAlpha)
        {
            if (bitmap->_transparency == 0)
                set_alpha_blender();
            else
                set_blender_mode(NULL, NULL, _trans_alpha_blender32, 0, 0, 0, bitmap->_transparency);

            draw_trans_sprite(virtualScreen, bitmap->_bmp, drawAtX, drawAtY);
        }
        else
        {
            draw_sprite_with_transparency(bitmap->_bmp, drawAtX, drawAtY, bitmap->_transparency);
        }
    }

    if (((_tint_red > 0) || (_tint_green > 0) || (_tint_blue > 0))
            && (_colorDepth > 8)) {
        // screen tint
        // This slows down the game no end, only experimental ATM
        set_trans_blender(_tint_red, _tint_green, _tint_blue, 0);
        draw_lit_sprite(virtualScreen, virtualScreen, 0, 0, 128);
        /*  This alternate method gives the correct (D3D-style) result, but is just too slow!
            if ((_spareTintingScreen != NULL) &&
                ((_spareTintingScreen->w != virtualScreen->w) || (_spareTintingScreen->h != virtualScreen->h)))
            {
              destroy_bitmap(_spareTintingScreen);
              _spareTintingScreen = NULL;
            }
            if (_spareTintingScreen == NULL)
            {
              _spareTintingScreen = create_bitmap_ex(bitmap_color_depth(virtualScreen), virtualScreen->w, virtualScreen->h);
            }
            tint_image(virtualScreen, _spareTintingScreen, _tint_red, _tint_green, _tint_blue, 100, 255);
            blit(_spareTintingScreen, virtualScreen, 0, 0, 0, 0, _spareTintingScreen->w, _spareTintingScreen->h);*/
    }

    ClearDrawList();
}