public abstract class LwjglZBufferStateUtil {
public static void apply(final ZBufferState state) {
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final ZBufferStateRecord record = (ZBufferStateRecord) context.getStateRecord(StateType.ZBuffer);
context.setCurrentState(StateType.ZBuffer, state);
enableDepthTest(state.isEnabled(), record);
if (state.isEnabled()) {
int depthFunc = 0;
switch (state.getFunction()) {
case Never:
depthFunc = GL11.GL_NEVER;
break;
case LessThan:
depthFunc = GL11.GL_LESS;
break;
case EqualTo:
depthFunc = GL11.GL_EQUAL;
break;
case LessThanOrEqualTo:
depthFunc = GL11.GL_LEQUAL;
break;
case GreaterThan:
depthFunc = GL11.GL_GREATER;
break;
case NotEqualTo:
depthFunc = GL11.GL_NOTEQUAL;
break;
case GreaterThanOrEqualTo:
depthFunc = GL11.GL_GEQUAL;
break;
case Always:
depthFunc = GL11.GL_ALWAYS;
}
applyFunction(depthFunc, record);
}
enableWrite(state.isWritable(), record);
if (!record.isValid()) {
record.validate();
}
}