public static void apply(final JoglRenderer renderer, final ColorMaskState state) {
final GL gl = GLContext.getCurrentGL();
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final ColorMaskStateRecord record = (ColorMaskStateRecord) context.getStateRecord(StateType.ColorMask);
context.setCurrentState(StateType.ColorMask, state);
if (state.isEnabled()) {
if (!record.isValid() || !record.is(state.getRed(), state.getGreen(), state.getBlue(), state.getAlpha())) {
gl.glColorMask(state.getRed(), state.getGreen(), state.getBlue(), state.getAlpha());
record.set(state.getRed(), state.getGreen(), state.getBlue(), state.getAlpha());
}
} else if (!record.isValid() || !record.is(true, true, true, true)) {
gl.glColorMask(true, true, true, true);
record.set(true, true, true, true);
}
if (!record.isValid()) {
record.validate();
}
}