public abstract class JoglCullStateUtil {
public static void apply(final JoglRenderer renderer, final CullState state) {
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final CullStateRecord record = (CullStateRecord) context.getStateRecord(StateType.Cull);
context.setCurrentState(StateType.Cull, state);
if (state.isEnabled()) {
final Face useCullMode = state.getCullFace();
switch (useCullMode) {
case Front:
setCull(GL.GL_FRONT, state, record);
setCullEnabled(true, state, record);
break;
case Back:
setCull(GL.GL_BACK, state, record);
setCullEnabled(true, state, record);
break;
case FrontAndBack:
setCull(GL.GL_FRONT_AND_BACK, state, record);
setCullEnabled(true, state, record);
break;
case None:
setCullEnabled(false, state, record);
break;
}
setGLPolygonWind(state.getPolygonWind(), state, record);
} else {
setCullEnabled(false, state, record);
setGLPolygonWind(PolygonWind.CounterClockWise, state, record);
}
if (!record.isValid()) {
record.validate();
}
}