Example #1
-1
void GLBackend::do_setStateBlend(State::BlendFunction function) {
    if (_pipeline._stateCache.blendFunction != function) {
        if (function.isEnabled()) {
            glEnable(GL_BLEND);

            glBlendEquationSeparate(BLEND_OPS_TO_GL[function.getOperationColor()], BLEND_OPS_TO_GL[function.getOperationAlpha()]);
            (void)CHECK_GL_ERROR();


            glBlendFuncSeparate(BLEND_ARGS_TO_GL[function.getSourceColor()], BLEND_ARGS_TO_GL[function.getDestinationColor()],
                BLEND_ARGS_TO_GL[function.getSourceAlpha()], BLEND_ARGS_TO_GL[function.getDestinationAlpha()]);
        } else {
            glDisable(GL_BLEND);
        }
        (void)CHECK_GL_ERROR();

        _pipeline._stateCache.blendFunction = function;
    }
}
Example #2
-1
void GLBackend::do_setStateBlend(State::BlendFunction function) {
    if (_pipeline._stateCache.blendFunction != function) {
        if (function.isEnabled()) {
            glEnable(GL_BLEND);

            static GLenum GL_BLEND_OPS[] = {
                GL_FUNC_ADD,
                GL_FUNC_SUBTRACT,
                GL_FUNC_REVERSE_SUBTRACT,
                GL_MIN,
                GL_MAX };

            glBlendEquationSeparate(GL_BLEND_OPS[function.getOperationColor()], GL_BLEND_OPS[function.getOperationAlpha()]);
            (void) CHECK_GL_ERROR();

            static GLenum BLEND_ARGS[] = {
                GL_ZERO,
                GL_ONE,
                GL_SRC_COLOR,
                GL_ONE_MINUS_SRC_COLOR,
                GL_SRC_ALPHA,
                GL_ONE_MINUS_SRC_ALPHA,
                GL_DST_ALPHA,
                GL_ONE_MINUS_DST_ALPHA,
                GL_DST_COLOR,
                GL_ONE_MINUS_DST_COLOR,
                GL_SRC_ALPHA_SATURATE,
                GL_CONSTANT_COLOR,
                GL_ONE_MINUS_CONSTANT_COLOR,
                GL_CONSTANT_ALPHA,
                GL_ONE_MINUS_CONSTANT_ALPHA,
            };

            glBlendFuncSeparate(BLEND_ARGS[function.getSourceColor()], BLEND_ARGS[function.getDestinationColor()],
                                BLEND_ARGS[function.getSourceAlpha()], BLEND_ARGS[function.getDestinationAlpha()]);
            (void) CHECK_GL_ERROR();
        } else {
            glDisable(GL_BLEND);
        }

        _pipeline._stateCache.blendFunction = function;
    }
}