public abstract class JoglClipStateUtil {
public static void apply(final JoglRenderer renderer, final ClipState state) {
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final ClipStateRecord record = (ClipStateRecord) context.getStateRecord(StateType.Clip);
context.setCurrentState(StateType.Clip, state);
final ContextCapabilities caps = context.getCapabilities();
final int max = Math.min(ClipState.MAX_CLIP_PLANES, caps.getMaxUserClipPlanes());
if (state.isEnabled()) {
for (int i = 0; i < max; i++) {
enableClipPlane(i, state.getPlaneEnabled(i), state, record);
}
} else {
for (int i = 0; i < max; i++) {
enableClipPlane(i, false, state, record);
}
}
if (!record.isValid()) {
record.validate();
}
}