public abstract class JoglBlendStateUtil {
public static void apply(final JoglRenderer renderer, final BlendState state) {
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final BlendStateRecord record = (BlendStateRecord) context.getStateRecord(StateType.Blend);
final ContextCapabilities caps = context.getCapabilities();
context.setCurrentState(StateType.Blend, state);
final GL gl = GLContext.getCurrentGL();
if (state.isEnabled()) {
applyBlendEquations(gl, state.isBlendEnabled(), state, record, caps);
applyBlendColor(gl, state.isBlendEnabled(), state, record, caps);
applyBlendFunctions(gl, state.isBlendEnabled(), state, record, caps);
applyTest(gl, state.isTestEnabled(), state, record);
if (caps.isMultisampleSupported()) {
applyAlphaCoverage(gl, state.isSampleAlphaToCoverageEnabled(), state.isSampleAlphaToOneEnabled(),
record, caps);
applySampleCoverage(gl, state.isSampleCoverageEnabled(), state, record, caps);
}
} else {
// disable blend
applyBlendEquations(gl, false, state, record, caps);
// disable alpha test
applyTest(gl, false, state, record);
// disable sample coverage
if (caps.isMultisampleSupported()) {
applyAlphaCoverage(gl, false, false, record, caps);
applySampleCoverage(gl, false, state, record, caps);
}
}
if (!record.isValid()) {
record.validate();
}
}